最近在搭建一个基于基于mmdetection的一个环境,遇到了各种gcc g++问题:
1. ''ImportError: ***/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/../../../libstdc++.so.6: version `CXXABI_1.3.11' not found (required by /DB/rhome/yuhangzhou/miniconda3/envs/open-mmlab/lib/python3.7/site ackages/torch/lib/libtorch_python.so)'',
解决办法:
then i remove original libstdc++.so.6, and run ''ln -s libstdc++.so.6.0.26 libstdc++.so.6'' after that, i run '''python setup.py develop' again,
2.error: command 'g++' failed with exit status 1
/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lm
/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lpthread
/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lc
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1
这个bug找了很多博客,都说是让安装g++,但是我是在服务器上搭环境,没有root权限
偶然间在下面连接中找到了解决办法:
https://*.com/questions/47512182/cannot-find-lfftw3-omp-error-when-compiling-a-third-party-package-how-to-lin
解决方法是找到包含-lm、-lpthread、-lc的文件,并将其连接到所需的文件夹下
以-lpthread为例:
(1)在终端中输入指令:ld -lpthread --verbose
找到succeeded路径,作为path 1
如上图的中path 1可以为/usr/lib/x86_64-linux-gnu/libpthread.so
(2)然后从错误信息:/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/ld: cannot find -lpthread
中获得path 2=/home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/
(3)最后在终端中输入指令:
ln -s path 1 path 2
(4)用类似的方法分别处理-lm、-lc
执行编译程序:python setup.py develop 或 bash compile.sh
示例:ln -s /usr/lib/x86_64-linux-gnu/libpthread.so /home1/wang-internship-1/anaconda3/envs/aerial/compiler_compat/
注:过程中会出现很多wanring,大约10分钟
但是结果会出现finished