当前位置:网站首页>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
边栏推荐
- Clickhouse native monitoring item, system table description
- 凤凰架构——架构师的视角
- Digital currency: far-reaching innovation
- 【等级测评师】等级测评师怎么报名?多少分及格?
- Test medal 1234
- Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
- Personal developed penetration testing tool Satania
- 一文读懂什么是MySQL索引下推(ICP)
- 3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充
- Auto-created primary key used when not defining a primary key
猜你喜欢

网络营销之四大误解

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

Icml2022 | utility theory of sequential decision making

《ClickHouse原理解析与应用实践》读书笔记(1)

How to move forward when facing confusion in scientific research? How to give full play to women's advantages in scientific research?

漫谈Clickhouse Join

Random talk about Clickhouse join

Deflection lock / light lock / heavy lock lock is healthier. How to complete locking and unlocking

个人开发的渗透测试工具Satania

ICML2022 | 序列决策的效用理论
随机推荐
笔记【JUC包以及Future介绍】
Personal developed penetration testing tool Satania
关于,奇安信检测代码漏洞,XSS系列解决
CentOS - enable / disable Oracle
ssh-server配置文件参数PermitRootLogin介绍
将博客搬至CSDN
mysql-批量更新
Markdown notes concise tutorial
Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
CA I ah, how many times Oh, ah sentence IU home Oh 11111
MySQL batch update
To the Sultanate of Anderson
Auto-created primary key used when not defining a primary key
Adobe-Photoshop(PS)-脚本开发-去除文件臃肿脚本
Digital currency: far-reaching innovation
Use the log server to output the topn of various Apache logs
Random talk about Clickhouse join
Ssh server configuration file parameter permitrootlogin introduction
你我他是谁
软工UML画图