An error is reported when running YOLO, ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found

Foreword:

I thought it would be easy to solve the problem I encountered when running YOLOv7's test.py, but I didn't expect it to take so long.

Reason for error:

libstdc++.so.6As shown below, this error is usually caused by a missing version of the library in your system GLIBCXX_3.4.29, and a certain software package or library requires this specific version of the library to function properly.

 Enter the following linux command to check whether the file is missing (generally speaking, it must be missing)

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

 It can be seen from the picture that there is indeed something missing.

Solution (recommended method 2):

Method 1:

1. Update the system : First, make sure your operating system has been updated to the latest version. Use the appropriate command, for example:

For Ubuntu/Debian systems:

sudo apt update
sudo apt upgrade

For CentOS/RHEL systems:

sudo yum update

2. Update the Conda environment : The error shown in your question occurs in Miniconda's Python environment. Try updating your Conda environment:

conda update --all

3. Update libstdc++.so.6 : If the above steps do not solve the problem, you can try updating libstdc++.so.6the library. You can try this by:

For Ubuntu/Debian systems:

sudo apt install libstdc++6

For CentOS/RHEL systems:

sudo yum install libstdc++.so.6
  1. After updating the library, restart your environment for the changes to take effect.

If the above methods still do not resolve the issue, you may need to investigate your system and environment settings more deeply to find out what is causing the issue.

Houji:

1. Use the following linux command to check whether there are other files of the same type in the current system and find a higher version.

sudo find / -name "libstdc++.so.6*"(注意这个命令需要权限,可以退出当前的账号进入管理员账户弄,但我的账号虽权限不够但也能查看?)

As shown in the picture, you can see that there are higher versions of the same type of files

Then use the following linux command to check whether this file contains the required version.

strings /home/lihao/miniconda3/envs/python39/lib/libstdc++.so.6.0.29 | grep GLIBCXX

(python39 is the name of the conda environment I created, don’t choose the wrong path ), the result is as shown in the figure.

 

 2. As shown in the picture above, it contains the version we need. Then do the following

①Copy this file to your project path.

Use the following linux command to copy the file.

cp /home/lihao/miniconda3/envs/python39/lib/libstdc++.so.6.0.29 /usr/lib/x86_64-linux-gnu/

There are two paths before and after that you need to pay attention to. The first parameter of the cp command is the path + file name marked in Figure 3, and the second parameter is the path marked in Figure 1. Don’t choose the wrong one. There are many solutions on the Internet. These two paths are not clearly stated. There is a space between the two paths! !

(Note that when doing this step, I was prompted that I did not have enough permissions, so I  sudo -i  to directly enter the root user to perform the operation. The cd ../.. command jumps to the root directory)

② Delete the connection on the original path.

Use the following Linux command to delete the connection on the original path.

sudo rm /usr/lib/x86_64-linux-gnu/libstdc++.so.6

(This path is still the path marked in Figure 1, but with the old file name added)

③ Establish a connection to the new file.

The final step is to create a new connection. The linux command is

sudo ln /lib/x86_64-linux-gnu/libstdc++.so.6.0.29 /usr/lib/x86_64-linux-gnu/libstdc++.so.6

(There are still two paths, the first parameter is the path of your own project + new file name, the second parameter is the path on your own project + old file name )

At this point, the problem is solved!

 

Successfully run test.py in YOLOv7:

 As shown in the figure, the running results are saved in runs/test/exp.

PS: Before running, remember to modify the parameters in test.py, as shown below.

 

 

Reference article: ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found - Zhihu

Guess you like

Origin blog.csdn.net/weixin_45819759/article/details/132408691