cuda 9.0 安装torch 0.4_No module named torch_sparse, 及pytorch-geometric安装

pip安装完pytorch-geometric之后,报错No module named torch_sparse,搜了一下,居然是一个大坑,总结一下

先上踩坑前辈:

踩坑总结:No module named torch_sparse​blog.csdn.net
eee7d424ea3a440dbdec3c0b1b1daf05.png
安装PyTorch-Geometric包之Installation PyG踩坑汇总= =​blog.csdn.net
eee7d424ea3a440dbdec3c0b1b1daf05.png
PyTorch Geometric环境安装​blog.csdn.net
ab1aa5c7ac320666bb8e219dc5955f33.png

小结:这个包就是个坑货(o(╥﹏╥)o)

下面两种方法实测都可以用,第二种更方面

1.下面是我安装的过程:

wget https://pytorch-geometric.com/whl/torch-1.5.0/torch_scatter-2.0.5%2Bcpu-cp37-cp37m-linux_x86_64.whl
pip install torch_scatter-2.0.5+cpu-cp37-cp37m-linux_x86_64.whl
wget https://pytorch-geometric.com/whl/torch-1.5.0/torch_sparse-0.6.6%2Bcpu-cp37-cp37m-linux_x86_64.whl
pip install torch_sparse-0.6.6+cpu-cp37-cp37m-linux_x86_64.whl
wget https://pytorch-geometric.com/whl/torch-1.5.0/torch_cluster-1.5.6%2Bcpu-cp37-cp37m-linux_x86_64.whl
pip install torch_cluster-1.5.6+cpu-cp37-cp37m-linux_x86_64.whl
wget https://pytorch-geometric.com/whl/torch-1.5.0/torch_spline_conv-1.2.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
pip install torch_spline_conv-1.2.0+cpu-cp37-cp37m-linux_x86_64.whl
pip install torch-geometric

参考了第一篇文章,直接下载对应的编译文件,注意要对应好你自己的python版本以及及其环境,我的是python3.7, ubuntu。

可以从这个网址找对应的whl文件:https://pytorch-geometric.com/whl/torch-1.5.0.html

c9cb36a5825ef25e3f8d85192a350a7d.png

2.官网还有个教程,也是能用的。

$ pip install torch-scatter==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
$ pip install torch-sparse==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
$ pip install torch-cluster==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
$ pip install torch-spline-conv==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-${TORCH}.html
$ pip install torch-geometric

where${CUDA}and${TORCH}should be replaced by your specific CUDA version (cpu,cu92,cu101,cu102) and PyTorch version (1.4.0,1.5.0), respectively. For example, for PyTorch 1.5.0/1.5.1 and CUDA 10.2

根据个人电脑配置,选择相应的选项。

例如:

$ pip install torch-scatter==latest+cpu -f https://pytorch-geometric.com/whl/torch-1.5.0.html
$ pip install torch-sparse==latest+cpu -f https://pytorch-geometric.com/whl/torch-1.5.0.html
$ pip install torch-cluster==latest+cpu -f https://pytorch-geometric.com/whl/torch-1.5.0.html
$ pip install torch-spline-conv==latest+cpu -f https://pytorch-geometric.com/whl/torch-1.5.0.html
$ pip install torch-geometric

另外的另外:

如果报错:libtorch_cpu.so: cannot open shared object file: No such file or directory,

那么,你的pytorch可能版本太低了,需要更新到torch1.5.0或者1.5.1。

至此,完美解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值