解决“Could not find module ‘D:\Anaconda\envs\DL\Lib\site-packages\torch_cluster_grid_cuda.pyd‘ ”

背景说明

在导入torch_geometric这个模块时,遇到了以下报错“Could not find module 'D:\Anaconda\envs\DL\Lib\site-packages\torch_cluster_grid_cuda.pyd' (or one of its dependencies). Try using the full path with constructor syntax”。

前一段时间时没有问题的,今天突然出现了这个问题。各种版本号都是匹配的,在绝对路径中这个文件也是存在的,不知道为什么,于是决定重新安装PyTorch Geometric (PyG) 库。

1.卸载旧的版本

pip uninstall torch_geometric torch_scatter torch_sparse torch_cluster torch_spline_conv

2.重新安装

①检查自己的 torch 和 cuda版本。

import torch
print(torch.__version__)
#检查torch版本;
 
import torch
print(torch.version.cuda)
#检查cuda版本;

以我的为例:

②安装相关依赖。依赖来源在这里pytorch-geometric.com/whl/

先安装4个,分别是1.torch-scatter 2.torch-sparse 3.torch-cluster 4.torch-spline-conv。注意修改对应的版本号。这个过程可能有一点慢,需要耐心等等。

pip install torch_scatter -f https://pytorch-geometric.com/whl/torch-1.12.0%2Bcu113.html

pip install torch_sparse -f https://pytorch-geometric.com/whl/torch-1.12.0%2Bcu113.html

pip install torch_cluster -f https://pytorch-geometric.com/whl/torch-1.12.0%2Bcu113.html

pip install torch_spline_conv -f https://pytorch-geometric.com/whl/torch-1.12.0%2Bcu113.html

如果是torch2.0.0,cuda117,就改成对应的torch-2.0.0%2Bcu117,以此类推。 

其他问题:

我在进行这一步时遇到了编译失败的问题,原因是没有Microoft C+ Build Tools。在给出网站下载安装后就可以顺利编译了,并且成功安装。

③下载安装完这四个文件以后还需要做一件事情,利用镜像源下载一个安装包:

pip install -U -i https://pypi.tuna.tsinghua.edu.cn/simple torch_geometric

最后打开JupyterNotebook导入需要的包,没有前面的报错,安装完毕。

3.总结

重新安装之后每个依赖都换成了更新的版本,新的版本可以正常使用。所以我认为是版本更新导致的问题。不知道和安装Microoft C+ Build Tools有没有关系。希望得到大佬的指点!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值