torch_scatter 导致ImportError: libcudart.so.10.1..

今天调用torch出现这种错误。搜了很多经验贴,有cuda与torch版本不对应的,有tensorflow不兼容的,等等。我把今天的解决步骤记录一下,大家遇到同样问题的依次排查,可以少走一点弯路。

1、查看 cuda 与 torch 是否对应

import torch
torch.cuda.is_available()
#输出:True则表示版本对应,False则表示版本不对应

如果输出为“False”,则是torch与cuda版本不对应问题,或者只能用cpu版本,绕道找其他经验贴解决即可。

cpu版本的安装如下所示:

conda install pytorch==1.8.1 torchvision==0.9.1 torchaudio==0.8.1 cpuonly -c pytorch

2、加载 torch.scatter 和 torch.sparse 库

import torch_scatter
import torch_sparse

我的加载不成功,说明问题出在这里。

利用pip命令重新安装一下

pip install torch-scatter
pip install torch-sparse

如果期间出现torch_scatter或torch_sparse安装不成功的问题,可以从下面网站下载对应的版本进行安装:https://data.pyg.org/whl/index.html

下载完成后,进入下载的whl文件的文件夹目录下,利用pip进行安装

pip install ***.whl

安装成功并且可以正确加载以后, libcudart.so.10.1 问题成功解决

你可能感兴趣的:(python,python,pytorch,深度学习)