报错解决:libcudart.so和libprotobuf.so链接库未找到

报错解决:libcudart.so和libprotobuf.so链接库未找到

此博客介绍了博主在编译软件包时遇到的两个报错,主要是libcudart和libprotobuf两个动态链接库未找到的问题,分析了其原因,并给出了解决方法。博主软硬件环境如下(供参考):

  • 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链接库未找到

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链接库未找到

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/,需要对应修改一下。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在Colab中报错"OSError: libcudart.so.10.1: cannot open shared object file: No such file or directory"是由于缺少CUDA运行时库文件引起的。CUDA是一个由NVIDIA开发的并行计算平台和编程模型,用于加速计算。缺少该文件可能是因为CUDA版本与Colab环境不兼容,或者没有正确安装CUDA解决该问题的方法有以下几种: 1. 检查CUDA版本:首先确认你正在使用的CUDA版本与Colab环境相匹配。可以通过运行命令"!nvcc --version"在Colab中查看当前的CUDA版本。如果版本不匹配,可以尝试使用Colab支持的其他CUDA版本。 2. 安装CUDA运行时库:如果确实缺少所需的CUDA运行时库文件,可以尝试手动安装它们。你可以从NVIDIA的官方网站下载所需的CUDA运行时库文件,并在Colab中安装。 3. 切换到CPU模式:如果你不需要使用GPU进行计算,你可以切换到CPU模式来避免CUDA相关的问题。可以通过在Colab中选择"Runtime" -> "Change runtime type",然后将硬件加速器更改为None,来切换到CPU模式。 4. 检查文件路径:如果报错中还包含文件路径相关的问题,例如"FileNotFoundError: [Errno 2] No such file or directory",请确保所需的文件存在于正确的路径下,并且路径命名正确。 总结来说,解决Colab中报错"OSError: libcudart.so.10.1: cannot open shared object file: No such file or directory"问题的方法有:检查CUDA版本、安装CUDA运行时库、切换到CPU模式和检查文件路径。希望这些方法能够帮助你解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ImportError: libcudart.so.10.2: cannot open shared object file: No such file or directory](https://blog.csdn.net/qq_38335768/article/details/121930591)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [python/pytorch 个人coding中的报错/异常](https://blog.csdn.net/WANGWUSHAN/article/details/105893877)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AI Player

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

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

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

打赏作者

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

抵扣说明:

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

余额充值