ここでSegmentation fault (core dumped)が出た.
from torch_sparse import SparseTensor, matmul, set_diag
原因
torchが指しているcuda driverのバージョンと実際のcuda driverのバージョンが違っていた.
https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html#frequently-asked-questions
このページの最後の方にSegmentation faultがよく起こっていると書いてある.インストールが失敗しているにも関わらず,成功しているように見えてしまうらしい.
Frequently Asked Questionsにチェックのやり方が書いてある
ちなみに何度かインストールにも失敗した.これも原因は同じだと思われる.インストールに失敗したときのエラーは次の通り.
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g_hg27p7/torch-sparse/setup.py'"'"'; __file__='"'"'/tmp/pip-install-g_hg27p7/torch-sparse/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7k5yvlfv
cwd: /tmp/pip-install-g_hg27p7/torch-sparse/
Complete output (57 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/diag.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/masked_select.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/select.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/convert.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/saint.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/spmm.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/spspmm.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/spadd.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/metis.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/index_select.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/reduce.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/sample.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/coalesce.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/eye.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/bandwidth.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/add.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/padding.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/cat.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/tensor.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/storage.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/__init__.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/rw.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/permute.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/utils.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/narrow.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/matmul.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/mul.py -> build/lib.linux-x86_64-3.8/torch_sparse
copying torch_sparse/transpose.py -> build/lib.linux-x86_64-3.8/torch_sparse
running egg_info
writing torch_sparse.egg-info/PKG-INFO
writing dependency_links to torch_sparse.egg-info/dependency_links.txt
writing requirements to torch_sparse.egg-info/requires.txt
writing top-level names to torch_sparse.egg-info/top_level.txt
reading manifest file 'torch_sparse.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*' found under directory 'test'
writing manifest file 'torch_sparse.egg-info/SOURCES.txt'
running build_ext
building 'torch_sparse._rw_cpu' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/csrc
creating build/temp.linux-x86_64-3.8/csrc/cpu
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITH_PYTHON -Icsrc -Ithird_party/parallel-hashmap -I/usr/local/lib/python3.8/dist-packages/torch/include -I/usr/local/lib/python3.8/dist-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.8/dist-packages/torch/include/TH -I/usr/local/lib/python3.8/dist-packages/torch/include/THC -I/usr/include/python3.8 -c csrc/rw.cpp -o build/temp.linux-x86_64-3.8/csrc/rw.o -O2 -Wno-sign-compare -DAT_PARALLEL_OPENMP -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -DTORCH_EXTENSION_NAME=_rw_cpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITH_PYTHON -Icsrc -Ithird_party/parallel-hashmap -I/usr/local/lib/python3.8/dist-packages/torch/include -I/usr/local/lib/python3.8/dist-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.8/dist-packages/torch/include/TH -I/usr/local/lib/python3.8/dist-packages/torch/include/THC -I/usr/include/python3.8 -c csrc/cpu/rw_cpu.cpp -o build/temp.linux-x86_64-3.8/csrc/cpu/rw_cpu.o -O2 -Wno-sign-compare -DAT_PARALLEL_OPENMP -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -DTORCH_EXTENSION_NAME=_rw_cpu -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
In file included from csrc/cpu/rw_cpu.cpp:3:
csrc/cpu/utils.h: In function ‘int64_t uniform_randint(int64_t, int64_t)’:
csrc/cpu/utils.h:40:3: error: ‘CHECK_LT’ was not declared in this scope; did you mean ‘CHECK’?
40 | CHECK_LT(low, high);
| ^~~~~~~~
| CHECK
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for torch-sparse
解決策
pytorchのcudaをちゃんと確認してインストールしなおす.多分torch_sparseも再インストールしたほうがいい