libcudart.so.10.2: cannot open shared object file: No such file or directory

情况一

nvidia-smi查看机器对应的cuda,然后再去官网https://pytorch.org/get-started/previous-versions/找到对应的torch版本下载即可,这里我的cuda是11.4,由于11.3的库已经能在11.4的环境里跑了,所以没有11.4,直接找到11.3的下载对应的torch就行了,由于我不需要torchvision和torchaudio,因此下面的命令是把torchvision和torchaudio删掉了的:

pip install torch==1.12.0+cu113 --extra-index-url https://download.pytorch.org/whl/cu113

情况二

整体过程

首先出现这个报错说明在/usr/local/cuda-11.5/lib64目录中确实没有libcudart.so.10.2这个文件,然后按照网上的教程,我在虚拟环境中安装了cuda10.2(由于用的是服务器,不用虚拟环境会出现提示有多个显卡驱动:Existing package manager installation of the driver found. It is strongly recommended that you remove this before continuing.,然后再安装就提示安装失败),结果又报错ImportError: libcudart.so.12: cannot open shared object file: No such file or directory,意思是还是要下载cuda12.1,最后通过这个帖子解决了问题:https://github.com/vllm-project/vllm/issues/1718

pip -q install --upgrade fschat accelerate autoawq vllm
pip install torch==2.1.0+cu121 torchvision==0.16.0+cu121 torchaudio==2.1.0 torchtext==0.16.0+cpu torchdata==0.7.0 --index-url https://download.pytorch.org/whl/cu121

细节

在虚拟环境中安装cuda 10.2

参考https://blog.csdn.net/Sir666888/article/details/122073675
首先用conda activate virtual_environment_name进入虚拟环境,再安装cuda 10.2:

conda install cudatoolkit=10.2 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/

到此为止cuda 10.2已经安装好了,下面为记录失败的尝试,可以直接跳过到下一章节~~
中间我还尝试官方的下载命令:
cuda 10.2官方:https://developer.nvidia.com/cuda-10.2-download-archive
cuda历史版本:https://developer.nvidia.com/cuda-toolkit-archive
此处参考教程:https://blog.csdn.net/qq_35082030/article/details/110387800
首先查看系统内核,选择需要的CUDA版本,通过命令cat /proc/version查看当前操作系统版本信息:
在这里插入图片描述
一开始不知道Ubuntu 9.4.0-1ubuntu1~20.04.2是什么意思,后面搜了下9.4.0指的应该是gcc版本(https://ubuntu.pkgs.org/20.04/ubuntu-updates-main-amd64/gcc-9_9.4.0-1ubuntu1~20.04.2_amd64.deb.html),所以我们Ubuntu版本应该为Ubuntu 20.04,因此我是这样选择的:
在这里插入图片描述

将下载好的文件执行以下操作:

  1. 先进入要下载的目录,执行命令:wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
  2. 然后在该目录下,使用chmod 755 cuda_10.2.89_440.33.01_linux.run更改文件的执行权限。
  3. 由于我们不是管理员用户,因此无法使用sudo安装,因此直接执行以下命令即可 sh cuda_10.2.89_440.33.01_linux.run,然后就出现这个页面:
    在这里插入图片描述
    我选择continue后显示失败。

在虚拟环境中安装cuda 12.1

安装好了cuda 10.2后,运行代码又报错了ImportError: libcudart.so.12: cannot open shared object file: No such file or directory,意思是还是要下载cuda12.1,最后通过这个帖子解决了问题:https://github.com/vllm-project/vllm/issues/1718
运行如下命令即可:

pip -q install --upgrade fschat accelerate autoawq vllm
pip install torch==2.1.0+cu121 torchvision==0.16.0+cu121 torchaudio==2.1.0 torchtext==0.16.0+cpu torchdata==0.7.0 --index-url https://download.pytorch.org/whl/cu121
  • 24
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当出现错误信息"ImportError: libcudart.so.10.2: cannot open shared object file: No such file or directory"时,这意味着系统找不到名为"libcudart.so.10.2"的共享对象文件。这个问题通常是由于缺少CUDA库文件或路径配置错误引起的。 要解决这个问题,可以按照以下步骤进行排查和解决: 1. 首先,检查您的系统是否正确安装了所需的CUDA库。您可以尝试使用命令"find . -name "libcudart.so.10.2""来查找该文件。如果找到了该文件,说明您的系统已经正确安装了CUDA库。 2. 如果未找到该文件,说明安装过程出现了错误。您需要重新安装对应版本的CUDA库。请确保您选择了与您的GPU兼容的正确版本。 3. 如果找到了该文件,但系统仍然无法找到它,那么您需要手动添加库文件的路径到系统的环境变量中。可以将库文件所在的路径例如"/opt/conda/envs/paddle/lib"添加到系统的LD_LIBRARY_PATH环境变量中。 通过按照上述步骤进行排查和解决,您应该能够解决"ImportError: libcudart.so.10.2: cannot open shared object file: No such file or directory"的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [ImportError: libcudart.so.10.1: cannot open shared object file: No such file or directory](https://blog.csdn.net/HaoZiHuang/article/details/115625025)[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%"] - *3* [ImportError: libcudart.so.10.2: cannot open shared object file: No such file or directory](https://blog.csdn.net/wjinjie/article/details/129924786)[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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值