该问题解决过程基于pytorch的编译过程。
git 版本升级
默认的git版本是1.8.3.1
,在执行git submodule update --init --recursive
的时候会没有反应,而另一台git 2.x的版本上是正常上,于是升级到同版本2.25.4
。
# 安装依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
yum install gcc perl-ExtUtils-MakeMaker
# 下载对应版本
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.25.4.tar.xz
# 解压
tar -xvf git-2.25.4.tar.xz
# 编译
make prefix=/usr/local/git all
# 安装
make prefix=/usr/local/git install
# 卸载旧版本
yum remove git
# 添加环境变量
sudo vim /etc/profile
添加一行:export PATH=$PATH:/usr/local/git/bin
source /etc/profile
# 验证
git --version
gcc版本升级
在编译执行python3 setup.py install
时,报错内容如下
-- Could not find ccache. Consider installing ccache to speed up compilation.
-- Performing Test COMPILER_WORKS
-- Performing Test COMPILER_WORKS - Success
-- Performing Test SUPPORT_GLIBCXX_USE_C99
-- Performing Test SUPPORT_GLIBCXX_USE_C99 - Failed
CMake Error at cmake/MiscCheck.cmake:63 (message):
The C++ compiler does not support required functions. This is very likely
due to a known bug in GCC 5 (and maybe other versions) on Ubuntu 17.10 and
newer. For more information, see:
https://github.com/pytorch/pytorch/issues/5229
Call Stack (most recent call first):
CMakeLists.txt:709 (include)
看起来是C++版本的问题,另一台fedora上边gcc 9.x的版本是正常的,所以直接升级
# 安装包
sudo yum install centos-release-scl
sudo yum install devtoolset-9-gcc*
# 直接替换旧版本
## 备份旧版本
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
mv /usr/bin/g++ /usr/bin/g++-4.8.5
mv /usr/bin/c++ /usr/bin/c++-4.8.5
## 创建软链接
ln -s /opt/rh/devtoolset-9/root/bin/gcc /usr/bin/gcc
ln -s /opt/rh/devtoolset-9/root/bin/g++ /usr/bin/g++
ln -s /opt/rh/devtoolset-9/root/bin/c++ /usr/bin/c++
# 验证
gcc --version
g++ --version
c++ --version