当前位置:网站首页>pytorch geometric torch-scatter和torch-sparse安装报错问题解决
pytorch geometric torch-scatter和torch-sparse安装报错问题解决
2022-06-30 21:21:00 【每天都想躺平的大喵】
问题
在安装torch-scatter、torch-sparse等报错
报错subprocess.CalledProcessError: Command ‘[‘which‘, ‘g++‘]‘ returned non-zero exit status 1.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-56zzyn27/torch-sparse/setup.py", line 46, in <module>
packages=find_packages(),
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 290, in run
self.run_command('build')
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
_build_ext.run(self)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 232, in build_extensions
self._check_abi()
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 370, in _check_abi
check_compiler_abi_compatibility(compiler)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 162, in check_compiler_abi_compatibility
if not check_compiler_ok_for_platform(compiler):
File "/home/aha/anaconda3/envs/geo/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 138, in check_compiler_ok_for_platform
which = subprocess.check_output(['which', compiler], stderr=subprocess.STDOUT)
File "/home/aha/anaconda3/envs/geo/lib/python3.6/subprocess.py", line 356, in check_output
**kwargs).stdout
File "/home/aha/anaconda3/envs/geo/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['which', 'g++']' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for torch-sparse
解决方案
step 1: 安装gcc和g++
这是因为gcc和g++没有安装,可以通过以下命令安装
sudo apt-get install build-essential
Ubuntu缺省情况下,并没有提供C/C++的编译环境,因此还需要手动安装。如果单独安装gcc以及g++比较麻烦,幸运的是,为了能够编译Ubuntu的内核,Ubuntu提供了一个build-essential软件包。
安装完户,一部分用户再重新执行pip命令安装scatter和sparse就可以了,但是我又遇到了问题。
step 2: 解决torch_scatter安装版本问题
先说解决方案,就是在安装命令中指明torch_scatter的版本pip install torch-scatter==2.0.6 -f https://data.pyg.org/whl/torch-1.6.0+cu101.html
也可以只用pip install torch-scatter==2.0.6
下面说一下解决问题的过程:
首先我是按照官网指导运行的以下命令:pip install -f https://data.pyg.org/whl/torch-1.6.0+cu101.html
发生报错,一部分报错内容如下:
csrc/scatter.cpp:135:30: error: no matching function for call to ‘at::Tensor::div_(at::Tensor&, const char [6])’
out.div_(count, "floor");
^
In file included from /opt/conda/lib/python3.7/site-packages/torch/include/ATen/Tensor.h:3:0,
from /opt/conda/lib/python3.7/site-packages/torch/include/ATen/Context.h:4,
from /opt/conda/lib/python3.7/site-packages/torch/include/ATen/ATen.h:5,
from /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /opt/conda/lib/python3.7/site-packages/torch/include/torch/script.h:3,
from csrc/scatter.cpp:2:
/opt/conda/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:649:12: note: candidate: at::Tensor& at::Tensor::div_(const at::Tensor&) const
Tensor & div_(const Tensor & other) const;
^~~~
/opt/conda/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:649:12: note: candidate expects 1 argument, 2 provided
/opt/conda/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:651:12: note: candidate: at::Tensor& at::Tensor::div_(c10::Scalar) const
Tensor & div_(Scalar other) const;
^~~~
/opt/conda/lib/python3.7/site-packages/torch/include/ATen/core/TensorBody.h:651:12: note: candidate expects 1 argument, 2 provided
error: command 'gcc' failed with exit status 1
仔细看了一下这段命令一开始执行的是:
也就是试图安装torch_scatter 2.0.9版本。
但是,我到官网给出的组合中去查找时,发现我的系统并不应该用2.0.9版本
https://data.pyg.org/whl/
以上链接中点击torch-1.6.0+cu101
列出以下torch_scatter版本
最高只有2.0.6版本,按照2.0.9版本与我的系统不符合,所以发生报错。至于为什么会出现这种情况,我也不太清楚。但是我们可以通过指定torch_scatter的版本来解决问题。pip install torch-scatter==2.0.6 -f https://data.pyg.org/whl/torch-1.6.0+cu101.html
参考博文:
https://blog.csdn.net/klarclm/article/details/8550931
https://blog.csdn.net/Iv_zzy/article/details/109310965
边栏推荐
- 电子方案开发——智能跳绳方案
- Metauniverse may become a new direction of Internet development
- Test medal 1234
- Clickhouse native monitoring item, system table description
- ArcGIS构建发布简单路网Network数据服务及Rest调用测试
- Learning summary
- “信任机器”为发展赋能
- ceshi deces
- sqlserver 字符串类型转换成小数或者整数类型
- Encryption and decryption and the application of OpenSSL
猜你喜欢

ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?

多表操作-外键约束

Oracle 数据库表结构 Excel 导出

报错:Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c.

Four Misunderstandings of Internet Marketing

Open source internship experience sharing: openeuler software package reinforcement test

Markdown笔记简明教程

It is urgent for enterprises to protect API security

科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?

Adobe-Photoshop(PS)-脚本开发-去除文件臃肿脚本
随机推荐
多表操作-外键约束
sdfsdf
关于,奇安信检测代码漏洞,XSS系列解决
Icml2022 | utility theory of sequential decision making
Upgrade Kube with unknown flag: --network plugin
Apply for vector bus protocol color picture wallpaper hanging picture, very good!
Reading notes of Clickhouse principle analysis and Application Practice (2)
《ClickHouse原理解析与应用实践》读书笔记(3)
Use the log server to output the topn of various Apache logs
vncserver: Failed command ‘/etc/X11/Xvnc-session‘: 256!
Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?
19.04 distributor
CA I ah, how many times Oh, ah sentence IU home Oh 11111
文本生成模型退化怎麼辦?SimCTG 告訴你答案
MySQL introduction, detailed installation steps and usage | dark horse programmer
防范未授权访问攻击的十项安全措施
ArcGIS construction and release of simple road network data service and rest call test
Test medal 1234
Markdown notes concise tutorial
Reading notes of Clickhouse principle analysis and Application Practice (1)