Windos torch_geometric安装踩坑教学

项目场景:

进行图神经网络的项目时,使用torch_geometric是,发现没有torch_sparse,于是进行安装


问题描述

使用命令:

pip install torch_sparse

出现以下错误

  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  Your compiler (cl 19.00.24210) may be ABI-incompatible with PyTorch!
  Please use a compiler that is ABI-compatible with GCC 5.0 and above.
  See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html.

  See https://gist.github.com/goldsborough/d466f43e8ffc948ff92de7486c5216d6
  for instructions on how to install GCC 5 or higher.
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                                !! WARNING !!

    warnings.warn(ABI_INCOMPATIBILITY_WARNING.format(compiler))
  error: [WinError 2] 系统找不到指定的文件。

但是输入命令

gcc -v

发现GCC版本应该是符合要求的,这就很奇怪了

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=f:/mingw/bin/../libexec/gcc/mingw32/9.2.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-9.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-static --enable-shared --enable-threads --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libgomp --disable-libvtv --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --disable-build-format-warnings --prefix=/mingw --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --enable-nls --with-pkgversion='MinGW.org GCC Build-2'
Thread model: win32
gcc version 9.2.0 (MinGW.org GCC Build-2)

原因分析:

Microsoft Visual studio 的cl.exe 文件和pytorch版本不匹配。
在网上找了很多方法,包括重装Microsoft Visual studio,更新GCC都不行始终解决不了


解决方案:

最后仔细分析问题,问题流程是这样的:
安装 torch_sparse->torch_sparse需要编译才能安装->cl和pytorch版本不匹配
既然最后一步解决不了,那干脆直接不对torch_sparse进行编译
直接下载编译后的torch_sparse

torch_sparse:https://github.com/rusty1s/pytorch_sparse

(1) 官网有这几个包的.whl文件,即编译好的各种torch_二进制包:

在这里插入图片描述

(2) 下载你需要的,跟你环境匹配的.whl文件

这里我的pytorch版本是1.13.1,cuda版本是11.6,选择对应的版本。
tips:
1.查看cuda版本:
在Anacoda Prompt中激活自己对应的虚拟环境后,输入命令:

(CA2) C:\WINDOWS\system32>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:36:24_Pacific_Standard_Time_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0

2.查看pytorch版本:
在Anacoda Prompt中激活自己对应的虚拟环境后,输入命令:

(CA2) C:\WINDOWS\system32>python
Python 3.8.0 (default, Nov  6 2019, 16:00:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

进入交互模式。然后输入:

>>> import torch
>>> torch.__version__
'1.13.1'

(3) 点击对应的链接进入

在这里插入图片描述

(5) 找到对应的文件点击下载

这里我的python版本为3.8,windos系统
在这里插入图片描述

(4) pip install + 刚才下载的.whl 文件的路径:

(CA2) C:\WINDOWS\system32>pip install E:\download\torch_sparse-0.6.17+pt113cu116-cp38-cp38-win_amd64.whl

(5)安装成功

Processing e:\download\torch_sparse-0.6.17+pt113cu116-cp38-cp38-win_amd64.whl
Requirement already satisfied: scipy in d:\softwares\anaconda\envs\ca2\lib\site-packages (from torch-sparse==0.6.17+pt113cu116) (1.10.0)
Requirement already satisfied: numpy<1.27.0,>=1.19.5 in d:\softwares\anaconda\envs\ca2\lib\site-packages (from scipy->torch-sparse==0.6.17+pt113cu116) (1.23.5)
Installing collected packages: torch-sparse
Successfully installed torch-sparse-0.6.17+pt113cu116
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值