question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to import torch_sparse

See original GitHub issue

Pytorch version : 1.4.0 Pytorch_sparse version: 0.5.1 Cuda version : 10.1 Build torch_sparse: source

When importing torch_sparse it fails to detect that it was indeed built with CUDA 10.1, as Pytorch.

$ python -c "import torch_sparse"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/localscratch/coulombc.5893633.0/.torch/lib/python3.6/site-packages/torch_sparse/__init__.py", line 36, in <module>
    f'Detected that PyTorch and torch_sparse were compiled with '
RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions. PyTorch has CUDA version 10.1 and torch_sparse has CUDA version 0.0. Please reinstall the torch_sparse that matches your PyTorch install.

as https://github.com/rusty1s/pytorch_sparse/blob/e78637ea3454965ac3aa35508f5e48d468dd7723/torch_sparse/__init__.py#L23 somehow returns -1.

The wheel was built on a host that does not have a GPU card, but the import also fails on a host with GPU device.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
llllodacommented, Feb 25, 2021

hi guys, I’m having this weird issue install torch-sparse is fine, but when it comes to import torch_sparse, it comes up with an issue like this:

RuntimeError: attribute assignment is not defined on torch.torch_sparse.storage.SparseStorage: File “XX/XX/anaconda3/envs/XX/lib/python3.6/site-packages/torch_sparse/storage.py”,line145 def empty(self): self = SparseStorage.new(SparseStorage) self._row = None ~~~~~~~~~~~~~ < — HERE self._rowptr = None self._value = None

so, i checked this storage.py file and everything seems fine, i have also uninstalled torch-sparse and re install it for many times.

emmmm, anyone know what is happening?

1reaction
rluria14commented, Jun 2, 2020

@rusty1s also getting this error on the import:

RuntimeError: Detected that PyTorch and torch_sparse were compiled with different CUDA versions. PyTorch has CUDA version 10.1 and torch_sparse has CUDA version 0.0. Please reinstall the torch_sparse that matches your PyTorch install.

scatter, cluster, and spline-conv seem to be importing fine. sparse is the only that is giving me an error.

any updates on how to fix this??

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while importing torch_sparse · Issue #215 - GitHub
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 ...
Read more >
How to fix Entry Point Not Found while import package from ...
I figure out the reason causing this problem due to problem of installing pytorch, torch-scatter and torch-sparse for cuda version, ...
Read more >
Installation — pytorch_geometric documentation
Unable to import *_cuda : You need to import torch first before importing any of the extension packages (see Issue#6). error: command '/usr/bin/nvcc'...
Read more >
Want to install : torch-sparse, getting this error - PyTorch Forums
ERROR : Command errored out with exit status 1: command: 'C:\Users\krishna\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.
Read more >
[pytorch] No module named torch-sparse error while using ...
[pytorch] No module named torch-sparse error while using torch-geometric ... Then you can import torch-geometric successfully!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found