pytorch_sparse
pytorch_sparse copied to clipboard
Error while importing torch_sparse
Hi,
I am trying to use torch-geometric, which depends on torch_sparse. When I try to import it, the following error occurs, which seems to be related to cuda version mismatch.
Ubuntu 16.04
Python: 3.8.13
Pytorch: 1.9.1.post3
cuda: 11.2
torch-sparse 0.6.13
The actual error message:
>>> from torch_sparse import transpose
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch_sparse/__init__.py", line 19, in <module>
torch.ops.load_library(spec.origin)
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch/_ops.py", line 104, in load_library
ctypes.CDLL(path)
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libcudart.so.10.2: cannot open shared object file: No such file or directory
Can you share same details on how you tried to install torch-sparse? For PyTorch 1.9.1, you may need to define a specific version requirement for it (see here:
pip install torch-sparse==0.6.12 -f ...
Thanks for the instructions. Here are my commands after creating my conda env with python 3.8. From the link you shared, I selected torch-1.9.1+cu11, from https://data.pyg.org/whl/torch-1.9.1%2Bcu111.html
conda install pytorch==1.9.1 torchvision==0.10.1 torchaudio==0.9.1 cudatoolkit=11.3 -c pytorch -c conda-forge
pip install torch-sparse==0.6.12 -f torch_sparse-0.6.12-cp39-cp39-linux_x86_64.whl
pip install torch-scatter==2.0.9 -f torch_scatter-2.0.9-cp39-cp39-linux_x86_64.whl
pip install torch-spline-conv==1.2.1 -f torch_spline_conv-1.2.1-cp39-cp39-linux_x86_64.whl
pip install torch-geometric
and here is the new error:
Traceback (most recent call last):
File "train_vectornet.py", line 9, in <module>
from torch_geometric.data import DataLoader
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch_geometric/__init__.py", line 4, in <module>
import torch_geometric.data
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch_geometric/data/__init__.py", line 1, in <module>
from .data import Data
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch_geometric/data/data.py", line 9, in <module>
from torch_sparse import SparseTensor
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch_sparse/__init__.py", line 15, in <module>
torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch/_ops.py", line 104, in load_library
ctypes.CDLL(path)
File "/home/hamidreza/anaconda3/envs/e2e/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/hamidreza/anaconda3/envs/e2e/lib/python3.8/site-packages/torch_sparse/_version_cpu.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
Note that you need to install via
pip install torch-sparse==0.6.12 -f https://data.pyg.org/whl/torch-1.9.1+cu111.html
pip install torch-scatter==2.0.9 -f https://data.pyg.org/whl/torch-1.9.1+cu111.html
pip install torch-spline-conv==1.2.1 -f https://data.pyg.org/whl/torch-1.9.1+cu111.html
Does that work for you? Can you also show me installation log of running pip install --verbose ...?
Note that in case you re-install, ensure that you uninstall all previous versions first.
This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?