torch_geometric安装避坑

总流程:

1. 查看cuda, pytorch, python版本;

2. 依次安装torch_scatter, torch_sparse, torch_cluster, torch_spline;

3. 安装torch_geometric

一. 查看cuda, pytorch, python版本

可选方法如下图,其中该样例的cuda, pytorch, python版本分别为10.2, 1.10.0, 3.7

二. 依次安装torch_scatter, torch_sparse, torch_cluster, torch_spline

1. 常见报错

(1)错误类型1

指令:pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cu102.html

即使按步骤一的结果指定了torch_scatter的版本,但还出现以下报错:

Failed to build torch-scatter
Installing collected packages: torch-scatter
    Running setup.py install for torch-scatter ... error
    ERROR: Command errored out with exit status 1:

(2)错误类型2

指令:pip install torch-cluster==latest+cu102 -f https://pytorch-geometric/com/whl/torch-1.10.0.html

但报错:找不到指定类型的版本ERROR: Could not find a version that satisfies the requirement torch-cluster==latest+cu102

 (3)错误类型3

安装没有错,但import torch-cluster时出现OSError: [WinError 127] 找不到指定的程序。:

 2. 正确安装

Step 1: 将torch_scatter, torch_sparse, torch_cluster, torch_spline的对应版本下载到本地,然后进行安装。

下载地址:https://pytorch-geometric.com/whl/

在以下页面根据对应的torch和cuda版本点击进入,

 根据对应的系统类型(linux or windows)和python版本选择torch_scatter, torch_sparse, torch_cluster, torch_spline下载。

 Step 2: cd到下载后的文件路径,pip install安装对应的4个包。下图以torch_cluster为例:

 Step 3: 验证是否安装成功。

下图以torch_cluster为例,import torch_cluster没有报错,则安装成功。

 三. 安装torch_geometric

此时,pip install torch_geometric,安装完成。

But 如果在import torch_geometric时,还出现TypeError: Expected ‘Iterator’ as the return annotation for __iter__ of SMILESParser, but found typing.Any的错误,这是因为pip install torch_geometric自动安装的版本不对,处理方法如下:

pip uninstall torch_geometric

pip install torch_geometric=2.0

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值