conda环境下“/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20‘ not found”问题解决

1 conda环境下运行python程序报错

conda环境下运行python所报的错误信息如下:

Traceback (most recent call last):
  File "/opt/faceswap/lib/cli/launcher.py", line 229, in execute_script
    process = script(arguments)
  File "/opt/faceswap/scripts/extract.py", line 61, in __init__
    self._extractor = Extractor(self._args.detector,
  File "/opt/faceswap/plugins/extract/pipeline.py", line 135, in __init__
    self._detect = self._load_detect(detector, rotate_images, min_size, configfile)
  File "/opt/faceswap/plugins/extract/pipeline.py", line 637, in _load_detect
    plugin = PluginLoader.get_detector(detector_name)(exclude_gpus=self._exclude_gpus,
  File "/opt/faceswap/plugins/plugin_loader.py", line 55, in get_detector
    return PluginLoader._import("extract.detect", name, disable_logging)
  File "/opt/faceswap/plugins/plugin_loader.py", line 197, in _import
    module = import_module(mod)
  File "/root/anaconda3/envs/faceswap/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1030, in _gcd_import
  File "", line 1007, in _find_and_load
  File "", line 986, in _find_and_load_unlocked
  File "", line 680, in _load_unlocked
  File "", line 850, in exec_module
  File "", line 228, in _call_with_frames_removed
  File "/opt/faceswap/plugins/extract/detect/s3fd.py", line 11, in 
    from scipy.special import logsumexp
  File "/root/anaconda3/envs/faceswap/lib/python3.9/site-packages/scipy/special/__init__.py", line 663, in 
    from . import _ufuncs
  File "_ufuncs.pyx", line 1, in init scipy.special._ufuncs
ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /root/anaconda3/envs/faceswap/lib/python3.9/site-packages/scipy/special/_ufuncs_cxx.cpython-39-x86_64-linux-gnu.so)
06/29/2023 15:07:40 CRITICAL An unexpected crash has occurred. Crash report written to '/opt/faceswap/crash_report.2023.06.29.150738070494.log'. You MUST provide this file if seeking assistance. Please verify you are running the latest version of faceswap before reporting

2 问题分析

从错误中分析可知,报错发生在/lib64/libstdc++.so.6,是GLIBCXX_3.4.20找不到所致。

2.1 命令行查看GLIBCXX的版本信息

命令查看显示如下:

[root@localhost faceswap]# strings /usr/lib64/libstdc++.so.6 |grep GLIBCXX*
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH

本地确实没有GLIBCXX_3.4.20

2.2 查看软连接

[root@localhost faceswap]ls -l /usr/lib64/libstdc++.so*
lrwxrwxrwx. 1 root root     19 5月   6 14:48 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.19
-rwxr-xr-x. 1 root root 995840 9月  30 2020 /usr/lib64/libstdc++.so.6.0.19

连接到linux系统的libstdc++.so.6.0.19

2.3 查看本地所有的“libstdc++.so.6”

 [root@localhost faceswap]# find / -name libstdc++.so.6*
/root/anaconda3/pkgs/libstdcxx-ng-9.1.0-hdf63c60_0/lib/libstdc++.so.6
/root/anaconda3/pkgs/libstdcxx-ng-9.1.0-hdf63c60_0/lib/libstdc++.so.6.0.26
/root/anaconda3/pkgs/libstdcxx-ng-9.1.0-hdf63c60_0/x86_64-conda_cos6-linux-gnu/sysroot/lib/libstdc++.so.6
/root/anaconda3/pkgs/libstdcxx-ng-9.1.0-hdf63c60_0/x86_64-conda_cos6-linux-gnu/sysroot/lib/libstdc++.so.6.0.26
/root/anaconda3/pkgs/libstdcxx-ng-11.2.0-h1234567_1/lib/libstdc++.so.6.0.29
/root/anaconda3/pkgs/libstdcxx-ng-11.2.0-h1234567_1/lib/libstdc++.so.6
/root/anaconda3/pkgs/libstdcxx-ng-12.2.0-h46fd767_19/lib/libstdc++.so.6
/root/anaconda3/pkgs/libstdcxx-ng-12.2.0-h46fd767_19/lib/libstdc++.so.6.0.30
/root/anaconda3/pkgs/gcc_impl_linux-64-12.1.0-hea43390_17/x86_64-conda-linux-gnu/lib/libstdc++.so.6
/root/anaconda3/pkgs/gcc_impl_linux-64-12.1.0-hea43390_17/x86_64-conda-linux-gnu/lib/libstdc++.so.6.0.30
/root/anaconda3/pkgs/libstdcxx-ng-13.1.0-hfd8a6a1_0/lib/libstdc++.so.6.0.31
/root/anaconda3/pkgs/libstdcxx-ng-13.1.0-hfd8a6a1_0/lib/libstdc++.so.6
/root/anaconda3/lib/libstdc++.so.6
/root/anaconda3/lib/libstdc++.so.6.0.26
/root/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/lib/libstdc++.so.6
/root/anaconda3/x86_64-conda_cos6-linux-gnu/sysroot/lib/libstdc++.so.6.0.26
/root/anaconda3/envs/test/lib/libstdc++.so.6
/root/anaconda3/envs/test/lib/libstdc++.so.6.0.29
/root/anaconda3/envs/vits/lib/libstdc++.so.6
/root/anaconda3/envs/vits/lib/libstdc++.so.6.0.29
/root/anaconda3/envs/voice/lib/libstdc++.so.6
/root/anaconda3/envs/voice/lib/libstdc++.so.6.0.29
/root/anaconda3/envs/wav2lip/lib/libstdc++.so.6
/root/anaconda3/envs/wav2lip/lib/libstdc++.so.6.0.29
/root/anaconda3/envs/whisper/lib/libstdc++.so.6
/root/anaconda3/envs/whisper/lib/libstdc++.so.6.0.29
/root/anaconda3/envs/faceswap/x86_64-conda-linux-gnu/lib/libstdc++.so.6
/root/anaconda3/envs/faceswap/x86_64-conda-linux-gnu/lib/libstdc++.so.6.0.30
/root/anaconda3/envs/faceswap/lib/libstdc++.so.6
/root/anaconda3/envs/faceswap/lib/libstdc++.so.6.0.31
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/local/cuda-11.3/nsight-systems-2021.1.3/target-linux-armv8/host-linux-armv8/libstdc++.so.6
/usr/local/cuda-11.3/nsight-systems-2021.1.3/host-linux-x64/libstdc++.so.6

3 解决方案

拷贝高版本的libstdc++.so到/usr/lib64目录下,并重新建立软连接

cp /root/anaconda3/envs/faceswap/lib/libstdc++.so.6.0.31  /usr/lib64/
ln -sf /usr/lib64/libstdc++.so.6.0.31 /usr/lib64/libstdc++.so.6

通过命令行查看

(faceswap) [root@localhost faceswap]# strings /usr/lib64/libstdc++.so.6 |grep GLIBCXX*
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_3.4.30
GLIBCXX_3.4.31

问题已经解决!

补充:

如果本地找不到GLIBCXX,升级gcc版本到10后再次查找,升级命令如下

安装centos-release-scl
yum install centos-release-scl -y

安装devtoolset
yum install devtoolset-10-gcc* -y

激活
scl enable devtoolset-10 bash

添加到环境变量
echo "source /opt/rh/devtoolset-10/enable" >> ~/.bash_profile
source /opt/rh/devtoolset-10/enable

查看当前gcc版本
gcc -v

你可能感兴趣的:(AI运行环境,conda,python,深度学习)