Linux学习与踩坑记录(持续更新版)


本博客记录了博主在学习Linux时遇到了各种各样的问题与解决方法,供大家参考,希望踩过的坑不踩第二次!

/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32‘ not found

原因

程序需要一个特定版本的 libstdc++.so.6 库(具体是 GLIBCXX_3.4.32 版本),但当前系统(Ubuntu 20.04)中安装的版本不满足要求。

解决方法

更推荐前两个方法,第三个方法有可能导致系统环境依赖冲突

  1. 将系统从Ubuntu 20.04升级到Ubuntu 22.04。
  2. 在Docker中开发。
  3. 添加一个高版本系统的源,直接升级libc6库。
# 编辑源文件
sudo vim /etc/apt/sources.list
# 添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ jammy main
# 更新源并升级
sudo apt-get update
sudo apt-get install libc6

invalid peer certificate: UnknownIssuer

具体报错如下:

  × Failed to download
  │ https://github.com/astral-sh/python-build-standalone/releases/download/20250409/cpython-3.11.12%2B20250409-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
  ├─▶ Request failed after 3 retries
  ├─▶ error sending request for url
  │   (https://github.com/astral-sh/python-build-standalone/releases/download/20250409/cpython-3.11.12%2B20250409-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz)
  ├─▶ client error (Connect)
  ╰─▶ invalid peer certificate: UnknownIssuer

原因

SSL 证书错误。

解决方法

在运行指令后添加--allow-insecure-host https://github.com

CMake x.x or higher is required. You are running version x.x

原因

cmake版本需要更新。

解决方法

卸载原版本的cmake:

# 可能连带卸载其他软件包,例如ros,需要再安装回来
sudo apt -y remove cmake

官网下载相应版本的cmake:

wget https://cmake.org/files/v3.23/cmake-3.23.0-linux-aarch64.sh

安装:

sudo bash ./cmake-3.23.0-linux-aarch64.sh --skip-licence --prefix=/usr/local --exclude-subdir

查看版本:

cmake --version

删除安装包:

rm cmake-3.23.0-linux-aarch64.sh

ImportError: libcudnn.so.8: cannot open shared object file: No such file or directory

原因

NVIDIA cuDNN是一个用于深度神经网络的GPU加速基元库。此报错的原因是没有安装cudnn或环境变量LD_LIBRARY_PATH未设置。

解决方法

官网下载对应版本,在此博主下载的是Local Installer for Linux x86_64 (Tar),解压后,将对应文件拷贝至cuda相应的文件夹。

sudo cp cudnn/include/cudnn*.h /usr/local/cuda-11.4/include
sudo cp -P cudnn/lib64/libcudnn* /usr/local/cuda-11.4/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

设置LD_LIBRARY_PATH环境变量:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64

libcudart.so not found

博主软硬件环境如下(供参考):

  • Linux
  • NVIDIA GeForce RTX 3080Ti
  • CUDA Driver Version 525.105.17
  • CUDA 11.1
  • gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0

libprotobuf.so是Google Protocol Buffers库的动态链接库文件。它用于在计算机系统中使用Protocol Buffers数据进行序列化和反序列化操作。

报错如下:

/usr/bin/ld: warning: libcudart.so.11.0, needed by XXX, not found.

原因

cuda未安装或cuda版本存在问题,抑或版本过低,抑或版本过高,需要安装CUDA >= 11.0 并且CUDA <= 12.0。

解决方法

前往官网,下载对应版本的cuda并安装,例如我选择安装cuda11.1,依次选择Linux-x86_64-Ubuntu-18.04-runfile(local),如下图所示。
在这里插入图片描述

注意,我选择deb(local)安装会报以下错误,因此选择runfile(local)进行安装。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cuda : Depends: cuda-12-1 (>= 12.1.1) but it is not going to be installed
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11 (main/dep11/Components-all.yml) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11-icons-small (main/dep11/icons-48x48.tar) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:1 and /etc/apt/sources.list.d/borglab-ubuntu-gtsam-release-4_0-bionic.list:3
E: Unable to correct problems, you have held broken packages.

运行如下命令,可以顺利安装:

wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
sudo sh cuda_11.1.0_455.23.05_linux.run

更多详细的安装过程,例如:运行.run文件后如何勾选选项等,可以参照我的另一篇博客CUDA安装

libprotobuf.so not found

博主软硬件环境如下(供参考):

  • Linux
  • NVIDIA GeForce RTX 3080Ti
  • CUDA Driver Version 525.105.17
  • CUDA 11.1
  • gcc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0

libcudart.so是CUDA运行时库的动态链接库文件。CUDA(Compute Unified Device Architecture)是由NVIDIA开发的用于并行计算的平台和编程模型。该库文件提供了在使用CUDA进行GPU编程时所需的运行时支持。

报错如下:

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.16/Modules/FindProtobuf.cmake:624 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:31 (find_package)

或者

/usr/bin/ld: warning: libprotobuf.so.17, needed by XXX, not found.

原因

protobuf未安装或系统默认安装的protobuf版本较低,需要按照高版本的protobuf。

解决方法

如果运行指令sudo apt install libprotobuf-dev无法安装对应版本的protobuf,则可以按照如下方法进行安装 :

  1. 前往protobuf的github官网下载对应版本(此处安装的是libprotobuf-dev==3.6.1)。
git clone https://github.com/protocolbuffers/protobuf.git
git checkout v3.6.1
  1. 运行如下命令进行安装:
./autogen.sh
./configure --prefix=/usr/local/protobuf #为了以后便于管理
make -j4 #多核编译加快速度
sudo make install
  1. 安装完之后,动态库的位置在/usr/local/protobuf/lib/,并创建(或修改)软链接:
sudo ln -s /usr/local/protobuf/lib/libprotoc.so.17.0.0 /usr/lib/libprotoc.so
sudo ln -s /usr/local/protobuf/lib/libprotobuf.so.17.0.0 /usr/lib/libprotobuf.so
sudo ln -s /usr/local/protobuf/lib/libprotobuf-lite.so.17.0.0 /usr/lib/libprotobuf-lite.so
# x86_64
sudo ln -s /usr/local/protobuf/lib/libprotobuf.so.17.0.0 /usr/lib/x86_64-linux-gnu/libprotobuf.so
sudo ln -s /usr/local/protobuf/lib/libprotobuf-lite.so.17.0.0 /usr/lib/x86_64-linux-gnu/libprotobuf-lite.so

这一点要注意:若你的电脑原protobuf库的位置不在/usr/local/protobuf/lib/,需要对应修改一下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI Player

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值