pytorch_geometric: Undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
📚 Installation
Environment
- OS: Ubuntu 18.04
- Python version: 3.6.9
- PyTorch version: 1.4.0
- CUDA/cuDNN version: 10.0
- GCC version: 7.4
- How did you try to install PyTorch Geometric and its extensions (pip, source): pip
- Any other relevant information: I have been using this library for a long time. I am quite surprised by this sudden error, even after couple of reinstalls.
Checklist
- I followed the installation guide.
- I cannot find my error message in the FAQ.
- I set up CUDA correctly and can compile CUDA code via
nvcc. - I have cloned the repository and tried a manual installation from source.
- I do have multiple CUDA versions on my machine.
- I checked if the official extension example runs on my machine.
- The offical extension example runs on my machine.
Additional context
Error log while importing:
>>> import torch
>>> import torch_scatter
Traceback (most recent call last):
File "/home/pranav/.local/lib/python3.6/site-packages/torch_scatter/__init__.py", line 13, in <module>
library, [osp.dirname(__file__)]).origin)
File "/usr/lib/python3/dist-packages/torch/_ops.py", line 106, in load_library
ctypes.CDLL(path)
File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/pranav/.local/lib/python3.6/site-packages/torch_scatter/_version.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pranav/.local/lib/python3.6/site-packages/torch_scatter/__init__.py", line 21, in <module>
raise OSError(e)
OSError: /home/pranav/.local/lib/python3.6/site-packages/torch_scatter/_version.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
>>> import torch_sparse
Traceback (most recent call last):
File "/home/pranav/.local/lib/python3.6/site-packages/torch_sparse/__init__.py", line 14, in <module>
library, [osp.dirname(__file__)]).origin)
File "/usr/lib/python3/dist-packages/torch/_ops.py", line 106, in load_library
ctypes.CDLL(path)
File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/pranav/.local/lib/python3.6/site-packages/torch_sparse/_version.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pranav/.local/lib/python3.6/site-packages/torch_sparse/__init__.py", line 22, in <module>
raise OSError(e)
OSError: /home/pranav/.local/lib/python3.6/site-packages/torch_sparse/_version.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 26 (9 by maintainers)
I have solved this problem. The reason is that: do not install pytorch via anaconda-navigator ! It will install both cpu and gpu versions, even though you only select the pytorch. You can download the specific version of the pytorch from:
https://download.pytorch.org/whl/torch_stable.html,
and this problem will be solved. All dependent packages are listed: cu101/torch-1.4.0-cp38-cp38-linux_x86_64.whl cu101/torchvision-0.5.0-cp38-cp38-linux_x86_64.whl torch_cluster-1.5.3+cu101-cp38-cp38-linux_x86_64.whl torch_scatter-2.0.4+cu101-cp38-cp38-linux_x86_64.whl torch_sparse-0.6.1+cu101-cp38-cp38-linux_x86_64.whl torch_spline_conv-1.2.0+cu101-cp38-cp38-linux_x86_64.whl
The author is right! Multi-versions of pytorch (CPU and GPU) result in this problem!
This error is usually explained by using multiple PyTorch or multiple CUDA versions, and the extensions get compiled with the one that you are not using within PyTorch. BTW, you can now also try out our Python binaries for a smoother installation.
I had the same problem in NextJournal (https://nextjournal.com) installing pytorch-geometric with conda. It was solved using the recommended pip installation procedure at https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
Hello, I ran into this issue after using a base image,
nvcr.io/nvidia/pytorch:22.09-py3, which uses a specific cherry-picked pytorch version,torch==1.7.0a0+8deb4fe. This version throws this exact error but for_version_cuda.so.I fixed this by using a more bare-bones Nvidia Cuda base image,
nvidia/cuda:11.7.1-devel-rockylinux8and running the following in the Dockerfile to install torch and torch-geometric via pip (you will need toyum install -y python38somewhere)I hope this helps anyone who ran into my exact issue with this error, but let me know if my suggestion is redundant for this thread.
Thanks for developing this great tool!
The original cause mentioned in https://github.com/pyg-team/pytorch_geometric/issues/999#issuecomment-593482341 is correct. This issue occurs when we have multiple PyTorch installations. However, this discussion lacks details on how to solve this issue for a beginner. Please refer to this StackOverflow answer, which describes how to solve this issue step-by-step in an anaconda virtual environment.
Thank you @dongweidongwei. That was the issue. Install from scratch with:
will pull pytorch-cpu, which will cause this issue. I need to install pytorch first, before install PyG. I think that was meant by the installation:
With
pytorch-1.9.0 | py3.9_cuda10.2_cudnn7.6.5_0everything is fine.Most people install with conda or pip , it is strange that the common way will result problem.
Ah, this makes sense. The only dependency specified by pyg is “pytorch” so conda is free to choose the cpu or gpu versions of pytorch. If the “flavor” matters, it needs to be specified in the dependences.
I build pytorch from source and got the same error. [v1.7.1] and cuda10.2