解决torch_geometric, torch_scatter, torch_sparse等库的兼容问题

如题,最近在安装OGB的时候快被各种库的兼容问题搞疯了,看了几个教程说要一个个版本一一对应,实在是太麻烦了,然后发现官网就有解决方案:

Installation — pytorch_geometric documentation

具体方法如下:

首先确保安装了torch和cuda(有gpu的话),然后检查版本:

python -c "import torch; print(torch.__version__)"
>>> 2.1.0
python -c "import torch; print(torch.version.cuda)"
>>> 12.1

我们这里pytorch是2.1.0版本, cuda是12.1版本,然后根据官网的这个表选择对应的版本:

它会告诉你相应的安装代码,如果你的版本不在表格里面,就通过修改这个里面torch和cuda的版本:

pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html

我们的安装代码如下:

pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu121.html

会直接帮你安装好兼容的库,注意torch_scatter, torch_sparse这些库一定要一起安装,然后通过

https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html

直接找你的torch和cuda版本对应的轮子,不然要么就是一直卡在building wheels,要么就是安装了之后不兼容!!!

这样的话就不用找每个库对应的版本了, 他会直接帮你安好兼容的版本!

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值