PyTorch Geometric / Installation errors

Causes and fixes for PyTorch Geometric installation errors

Common errors when installing PyTorch Geometric and extensions such as torch_scatter and torch_sparse, listed by exact message, each with its cause and fix.

Short answer

Extensions such as torch_scatter and torch_sparse are compiled for one specific PyTorch and CUDA version, so after a PyTorch upgrade or with a CUDA mismatch, import fails with undefined symbol.

Setting up your environment this way avoids most errors on this page.

PracticeWhat happens if you skip it
Install the main package with pip install torch_geometric. Since PyG 2.3 it needs nothing beyond PyTorch.Extra torch_scatter and torch_sparse builds that do not match PyTorch become the source of errors.
If you do need the extensions, install them from the data.pyg.org wheel URL that exactly matches torch.__version__ and torch.version.cuda.A plain pip install torch_scatter compiles from source or picks a mismatched version.
After upgrading PyTorch, uninstall and reinstall pyg_lib, torch_scatter and torch_sparse together.Old extensions stay in the environment and import fails with undefined symbol or Expected PyTorch version.
For PyTorch newer than 2.5, install the PyG extensions with pip, not conda.conda has no extension builds for newer PyTorch, so you get old versions or an unsolvable environment.
Use a separate virtual environment for graph neural network projects.When another project upgrades PyTorch, the PyG extensions break.

Troubleshooting by error message

Find your exact error message. Each entry gives the cause, the fix, and what may come up after the fix.

OSError: .../torch_sparse/_version_cuda.so: undefined symbol: _ZN3c1017RegisterOperatorsD1Ev

Cause: The installed torch_sparse was compiled for a different PyTorch version than the one you have.

Fix: Get your versions with python -c "import torch; print(torch.__version__, torch.version.cuda)", then reinstall the extensions from the matching https://data.pyg.org/whl/torch-VERSION+cuVERSION.html.

What may come next: Reinstalling only torch_sparse may leave torch_scatter and other extensions failing the same way, so reinstall them together.

undefined symbol: make_function_schema

Cause: The PyTorch or CUDA version differs from the one the extensions were installed for.

Fix: Check the versions, then reinstall the extensions from the matching wheel URL with pip install --force-reinstall --no-cache-dir.

RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions.

Cause: torch_sparse and PyTorch use different CUDA versions, typically after a source build or the wrong wheel URL.

Fix: Use the same CUDA version for both: if PyTorch is cu121, install the extensions from the cu121 wheel URL too.

What may come next: If you build from source instead, use pip install --no-build-isolation, or the build uses a different PyTorch.

OSError: libcusparse.so.11: cannot open shared object file: No such file or directory

Cause: The extension cannot find the CUDA libraries bundled with PyTorch, or it loads a different system CUDA.

Fix: Add the conda environment lib folder to LD_LIBRARY_PATH, for example export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"; if that is not enough, reinstall the extensions for the PyTorch CUDA version.

What may come next: In PyCharm or Jupyter, an LD_LIBRARY_PATH set in the terminal does not apply; set it in the run configuration instead.

undefined symbol: __cudaPopCallConfiguration (after building torch_scatter from source)

Cause: The nvcc used for the build does not match the CUDA version PyTorch uses.

Fix: Point CUDA_HOME at the CUDA version PyTorch uses, uninstall torch_scatter, delete the build folder, and rebuild with pip install --no-cache-dir torch-scatter.

What may come next: A source build takes minutes to tens of minutes and must be redone whenever you change PyTorch versions.

AttributeError: 'NoneType' object has no attribute 'origin' (on import torch_sparse)

Cause: The torch_sparse install did not build the CUDA library files, only the CPU ones.

Fix: Uninstall it and reinstall from the wheel URL matching the PyTorch CUDA version; for a source build, set FORCE_CUDA=1.

RuntimeError: Expected PyTorch version 1.4 but found version 1.10.

Cause: After a PyTorch upgrade, an old torch_cluster or other extension is still in the environment.

Fix: Uninstall the old extension; recent PyG no longer needs torch_cluster because pyg_lib provides that functionality, so reinstall pyg_lib if needed.

Scientify is a cloud computer with research software installed and AI agents such as Codex and Claude Code built in. Describe what you need in one sentence, for example "train a graph neural network on this molecular dataset to predict solubility and report the test error", and the agent uses the preinstalled PyTorch Geometric to do the modeling and computation, with no software to install and no code to write.

Compared with installing more on your own computer, the cloud computer already has PyTorch Geometric 2.8.1 with the matching PyTorch 2.14.1, so there are no extension, PyTorch and CUDA versions to match, and runs continue after you close your laptop.

The cloud computer comes with more computing power: CPU and GPU clusters can be called on demand for large-scale scientific computing. Compute is billed by the minutes you actually use, so nothing is wasted.

Cloud computer
4 vCPU · 8 GB
Top configuration, for data processing and small to medium jobs
Callable GPU
96 GB VRAM
Up to an RTX PRO 6000 per GPU; H800 80 GB and up to 8 × A10G also available
Callable CPU
224 cores · 3 TB
Largest spec, for large parallel computations

References

Frequently asked questions

Are torch_scatter and torch_sparse still required?

No. Since PyG 2.3, pip install torch_geometric depends only on PyTorch; install these extensions only when you need specific accelerated features.

How do I find extensions that match my PyTorch?

Run python -c "import torch; print(torch.__version__, torch.version.cuda)", then pip install pyg_lib torch_scatter torch_sparse -f https://data.pyg.org/whl/torch-VERSION+cuVERSION.html.

Can I install PyG on a CPU-only machine?

Yes. Use the CPU build of PyTorch and install the extensions from the torch-VERSION+cpu wheel URL.

Train graph neural networks with Scientify without setup

Upload your data, describe the computation, and Scientify runs it on a cloud computer that is already set up. New accounts get a free cloud computer and US$5 in credit.