首页 > 解决方案 > CUDA版本的包没有导入?

问题描述

首先,我安装了 torch 1.1.0,然后安装了它的依赖项。所以,我可以导入 torch_scatter 1.2.0 但是在导入 torch_scatter.scatter_cuda 时出现此错误:

 import torch_scatter.scatter_cuda
ModuleNotFoundError: No module named 'torch_scatter.scatter_cuda'

我安装了 Cuda v10 并且有一个 GPU。这段代码的所有要求都是通过 pip 在我的虚拟环境中一次性安装的。

标签: pythonterminalpippytorchtorch

解决方案


As pointed out by phd - it looks like the setup.py file of pytorch_scatter checks for and uses an available cuda installation automatically.

Also in the version you are using as seen here:

...
if CUDA_HOME is not None:
    ext_modules += [
                   CUDAExtension('torch_scatter.scatter_cuda',
                  ['cuda/scatter.cpp', 'cuda/scatter_kernel.cu'])
    ]
...

Might be a question of whether CUDA_HOME is available.

Installing from source might give you more information as suggested here.


推荐阅读