集群报错:ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.29’ not found
集群报上述错误,没有root权限,不想麻烦管理员的解决办法:
问题描述
ImportError: /lib64/libstdc++.so.6: version GLIBCXX_3.4.29' not found
错误如下:
from mmcv.ops import sigmoid_focal_loss as _sigmoid_focal_loss File "/home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/ops/__init__.py", line 2, in <module> from .assign_score_withk import assign_score_withk File "/home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/ops/assign_score_withk.py", line 6, in <module> '_ext', ['assign_score_withk_forward', 'assign_score_withk_backward']) File "/home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext ext = importlib.import_module('mmcv.' + name) File "/home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/_ext.cpython-37m-x86_64-linux-gnu.so)
确认报错
查看一下报错环境位置的libstdc++.so.6情况
strings /home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/_ext.cpython-37m-x86_64-linux-gnu.so | grep GLIBC
发现确实没有 version `GLIBCXX_3.4.29’
(open-mmlab) [xxx@gpu07 mmsegmentation]$ strings /home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/_ext.cpython-37m-x86_64-linux-gnu.so | grep GLIBCGLIBC_2.2.5GLIBC_2.14GLIBCXX_3.4.18GLIBCXX_3.4.26GLIBCXX_3.4.9GLIBCXX_3.4
原因分析:
因为安装的gcc版本比较高,生成的动态库没有替换老版本gcc的动态库,GLIBCXX中的版本比较低
解决方案:
将gcc最新版本的动态库替换系统中老版本的动态库
- 如果不想麻烦管理员,先找找其他环境中的 libstdc++.so.6文件,看有没有自己需要的
find /home/xxx/tools/miniconda3 -name libstdc++.so.6/home/xxx/tools/miniconda3/pkgs/libstdcxx-ng-9.3.0-hd4cf53a_17/lib/libstdc++.so.6/home/xxx/tools/miniconda3/pkgs/libstdcxx-ng-11.2.0-he4da1e4_16/lib/libstdc++.so.6/home/xxx/tools/miniconda3/pkgs/libstdcxx-ng-11.2.0-h1234567_0/lib/libstdc++.so.6/home/xxx/tools/miniconda3/pkgs/libstdcxx-ng-12.1.0-ha89aaad_16/lib/libstdc++.so.6/home/xxx/tools/miniconda3/lib/libstdc++.so.6/home/xxx/tools/miniconda3/envs/i2v/lib/libstdc++.so.6 /home/xxx/tools/miniconda3/envs/pytorch1.2/lib/libstdc++.so.6
- 用以下命令查看上述任意一个
strings /home/xxx/tools/miniconda3/envs/i2v/lib/libstdc++.so.6 | grep GLIBC
其中有环境中有报错中要求的版本
3. 拷贝需要的版本
然后只需要cd到报错位置,将libstdc++.so.6删除,将metage环境下指定位置(指定位置是通过前面的find命令找的,一般在 ~/miniconda3/envs/环境名/lib/ 下就有)的libstdc++.so.6拷贝过来就行了;
# 删除报错位置的libstdc++.so.6文件:rm -rf /home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/_ext.cpython-37m-x86_64-linux-gnu.so # 切换到报错位置cd /home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/# 复制刚才找到满足要求的环境目录到当前位置cp /home/xxx/tools/miniconda3/envs/i2v/lib/libstdc++.so.6 ./# 查看报错位置的libstdc++.so.6strings /home/xxx/tools/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/_ext.cpython-37m-x86_64-linux-gnu.so.6 | grep GLIBC
如下图
参考
https://blog.csdn.net/weixin_52602016/article/details/124478222?