Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'scatter_cuda' #8

Closed
shagunsodhani opened this issue Oct 1, 2018 · 6 comments
Closed

ModuleNotFoundError: No module named 'scatter_cuda' #8

shagunsodhani opened this issue Oct 1, 2018 · 6 comments

Comments

@shagunsodhani
Copy link

shagunsodhani commented Oct 1, 2018

Hey

I am trying to use the package. I installed it via both pip and source. It works fine on the cpu but when I try to import scatter_cuda on a gpu, it gives me the following error:

from torch_scatter import scatter_max

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch_scatter/__init__.py", line 3, in <module>
    from .mul import scatter_mul
  File "/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch_scatter/mul.py", line 3, in <module>
    from torch_scatter.utils.ext import get_func
  File "/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch_scatter/utils/ext.py", line 5, in <module>
    import scatter_cuda
ModuleNotFoundError: No module named 'scatter_cuda'

I made sure to check te pytorch version ('0.4.1') and setup $PATH and $CPATH . For reference, they look like

$PATH=...anaconda3/envs/torch0.4.1/bin::/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin
$CPATH=/usr/local/cuda/include

Edit:

Running python3 setup.py test returns

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
/usr/local/cuda/bin/nvcc -I/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch/lib/include -I/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch/lib/include/TH -I/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/u/sodhanis/anaconda3/envs/torch4/include/python3.6m -c cuda/scatter_kernel.cu -o build/temp.linux-x86_64-3.6/cuda/scatter_kernel.o -DTORCH_EXTENSION_NAME=scatter_cuda -D_GLIBCXX_USE_CXX11_ABI=0 --compiler-options '-fPIC' -std=c++11
/u/sodhanis/anaconda3/envs/torch4/lib/python3.6/site-packages/torch/lib/include/ATen/Half-inl.h(17): error: identifier "__half_as_short" is undefined

1 error detected in the compilation of "/tmp/tmpxft_00001462_00000000-7_scatter_kernel.cpp1.ii".
error: command '/usr/local/cuda/bin/nvcc' failed with exit status 2
@rusty1s
Copy link
Owner

rusty1s commented Oct 2, 2018

Hi,

error: identifier "__half_as_short" is undefined

seems to be a PyTorch/GPU/CUDA error. Which GPU and CUDA version are you using?

@rusty1s
Copy link
Owner

rusty1s commented Oct 2, 2018

Related pytorch/pytorch#3361

@shagunsodhani
Copy link
Author

I am using Cuda 8.0. The GPU is allocated from a pool of resources though it is most likely to be P100. The cuda_fp16.h file is in the right directory. Given this is a managed cluster, Cuda installation is more than likely to be correct.

The log of rm -rf build/ && python3 setup.py install fixes the error for me :)

@rusty1s
Copy link
Owner

rusty1s commented Oct 2, 2018

Glad that it is now working. What was the exact problem?

@shagunsodhani
Copy link
Author

I am not sure. I just followed your suggestion of rm -rf build/ && python3 setup.py install. I did not change my cuda version (since its a managed environment, I cant even if I want to) nor did I reinstall PyTorch. Also for the other modules like pytorch_sparse etc, installing from source worked while pip install had issues.

@zhangyuygss
Copy link

Have the same problem when install from pip, build from source worked fine. I'm using cuda9.2 on ubuntu18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants