ModuleNotFoundError: No module named 'torch_sparse.unique_cuda'

原因:pip install torch_sparse 时,编译器没有找到 cuda 或 cudann 的环境变量,只生成了 cpu 版本的 torch_sparse,而省略了和cuda相关的模块。

解决方案:

手动安装 cuda,cudann

参考教程:

https://blog.csdn.net/Mind_programmonkey/article/details/99688839#commentBox

需要注意,cuda,cudann 和 visual studio 版本之间的对应。比如:cuda 10.0, cudann 7.6,vs 2017
ModuleNotFoundError: No module named 'torch_sparse.unique_cuda'_第1张图片

重新安装 torch_sparse

(pytorch) C:\Users\MONKEY\Desktop>pip uninstall torch-sparse
Uninstalling torch-sparse-0.4.0:
  Would remove:
    d:\miniconda3\envs\pytorch\lib\site-packages\test\*
    d:\miniconda3\envs\pytorch\lib\site-packages\torch_sparse-0.4.0.dist-info\*
    d:\miniconda3\envs\pytorch\lib\site-packages\torch_sparse\*
  Would not remove (might be manually added):
    d:\miniconda3\envs\pytorch\lib\site-packages\test\test_backward.py
    d:\miniconda3\envs\pytorch\lib\site-packages\test\test_forward.py
    d:\miniconda3\envs\pytorch\lib\site-packages\test\test_max_min.py
    d:\miniconda3\envs\pytorch\lib\site-packages\test\test_multi_gpu.py
    d:\miniconda3\envs\pytorch\lib\site-packages\test\test_std.py
Proceed (y/n)? y
  Successfully uninstalled torch-sparse-0.4.0
(pytorch) C:\Users\MONKEY\Desktop>pip install torch-sparse
Collecting torch-sparse
  Using cached https://files.pythonhosted.org/packages/b0/0a/2ff678e0d04e524dd2cf990a6202ced8c0ffe3fe6b08e02f25cc9fd27da0/torch_sparse-0.4.0.tar.gz
Requirement already satisfied: scipy in d:\miniconda3\envs\pytorch\lib\site-packages (from torch-sparse) (1.3.1)
Requirement already satisfied: numpy>=1.13.3 in d:\miniconda3\envs\pytorch\lib\site-packages (from scipy->torch-sparse) (1.16.5)
Building wheels for collected packages: torch-sparse
  Building wheel for torch-sparse (setup.py) ... done
  Created wheel for torch-sparse: filename=torch_sparse-0.4.0-cp36-cp36m-win_amd64.whl size=285224 sha256=7a88deb0de81c8b0095ac5362aaabe291737e8d3aa587b5b0e6309a706be092b
  Stored in directory: C:\Users\MONKEY\AppData\Local\pip\Cache\wheels\9d\83\0a\38ea460df5586a075b877fe089619e5238487712a0645940bd
Successfully built torch-sparse
Installing collected packages: torch-sparse
Successfully installed torch-sparse-0.4.0

你可能感兴趣的:(#,深度学习,乱七八糟,cuda,安装,编译)