torch_scatter ,torch-sparse,torch-cluster等系列安装

由于我自己也下了好几次这几个包,所以我自己也写篇文章,亲测有效。(期间真的是太痛苦了)

首先我们需要知道torch-scatter,torch-sparse,torch-cluster,torch-spline-conv等库的安装是需要与torch和cuda版本对应的,所以这就是为什么通常直接安装后不可以用的原因。

1.查看你的torch和cuda版本

import torch
print(torch.__version__)
print(torch.version.cuda)

2.安装:

参考官网:Installation — pytorch_geometric documentationicon-default.png?t=N7T8https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html可以直接用如下命令:

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

其中 {TORCH} 替 换 为 torch 的 版 本 号 ,{CUDA} 替换为上面查询得到的cuda版本号。例如我的是torch 1.13.0 和 cuda11.7,我使用的安装命令如下:

pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.13.0+cu117.html

3.如果失败了

要么是没对应上版本,要么就是存在残存的文件。建议完全卸载后再重新安装。

  • 14
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你遇到 "ModuleNotFoundError: No module named 'torch_scatter'" 的错误时,这意味着你的Python环境中缺少了名为 'torch_scatter' 的模块。有几种可能的解决方法可以尝试: 1. 使用pip安装 'torch_scatter' 模块:在命令行中运行 "pip install torch_scatter" 来安装该模块。请确保你的pip版本是最新的,也可以尝试使用 "pip3" 命令。 引用 2. 检查是否缺少C编译器:有时,缺少C编译器也会导致这个错误。你可以尝试在VSCode中安装一个C语言插件,如C/C++插件,以确保你的环境中有可用的编译器。 引用 3. 从GitHub下载并安装 'torch_scatter':你可以尝试从GitHub中下载 'torch_scatter' 的源代码,并按照安装说明进行安装。你可以通过访问 https://github.com/rusty1s/pytorch_scatter 来获取源代码。 引用 请注意,使用Gitbub下载和安装 'torch_scatter' 时,命令应该是 "conda install pytorch-scatter -c pyg",而不是一个URL链接。 引用 希望这些方法能够帮助你解决 "ModuleNotFoundError: No module named 'torch_scatter'" 的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [安装torch_scatter出现的问题:ModuleNotFoundError: No module named ‘torch_scatter](https://blog.csdn.net/qq_40571009/article/details/124786332)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [[Pytorch执行报错] ModuleNotFoundError: No module named ‘torch_sparse‘/‘torch_scatter‘/‘torch_...](https://blog.csdn.net/qianxie1/article/details/122445036)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值