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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值