OSError: libcublas.so.11: cannot open shared object file: No such file or directory【import onnx报错】

  • 🥇 版权: 本文由【墨理学AI】原创、在CSDN首发、各位大佬、敬请查阅
  • 🎉 声明: 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️

9-6


📕 遇到报错


OSError: libcublas.so.11: cannot open shared object file: No such file or directory


📕 简单分析一下,我为什么会遇到这个错误


在 onnx 模型 转 TVM 模型的任务中,我无意中同时安装了 onnxruntime 和 onnxruntime-gpu

导致 import onnxruntime as rt 这行代码,默认就会使用 onnxruntime-gpu ,从而 需要 用到 libcudart.so.11.0 系列相关动态库;

实际上,我的当前代码不需要用到 onnxruntime-gpu,因此我选择 pip uninstall onnxruntime-gpu

这里存在一个库的逻辑错误:
onnxruntime-gpu 的存在 对于 onnxruntime 有较大影响,导致我的 conda 环境必须 pip uninstall onnxruntime 和 onnxruntime-gpu 然后再 重新 pip install onnxruntime 代码才恢复正常;

所以对于我的问题而言实际解决方法是如下操作:

# 无意安装了 onnxruntime-gpu
pip install onnxruntime
pip install onnxruntime-gpu

# 两个全部 uninstall 干净
pip uninstall onnxruntime-gpu
pip uninstall onnxruntime

# 重新只安装 onnxruntime
pip install onnxruntime

📕 遇到这个错误,我的第一解决思路【也有作用】


基础条件,系统Cuda 内核版本足够高

2-1

解决思路

  • 在服务器 find libcudart.so.11.0 存在的地方,然后把该库以及其软连接全部 copy 到当前环境需要的 位置

代码操作如下

 find -name libcublas.so.11
 
./anaconda3/pkgs/cudatoolkit-11.1.1-h6406543_8/lib/libcublas.so.11
./anaconda3/envs/SampleSolution/lib/libcublas.so.11

# copy 到当前环境需要的位置
cp -r ./anaconda3/envs/SampleSolution/lib/libcublas.so.11* ./anaconda3/envs/torch15/lib/

存在问题

  • 这样操作的确可以解决 OSError: libcublas.so.11: cannot open shared object file: No such file or directory 的问题;
  • 然而又会出现 OSError: libcublasLt.so.11: cannot open shared object file: No such file or directory 的报错;
  • 解决思路,和处理 libcublas.so.11 的方式一样即可;
  • 以此类推

📕 遇到这个错误,我的第二解决思路【经验证,是正确的解决思路】


基础条件,系统Cuda 内核版本足够高

2-1

通过 conda list 命令 我们可以发现 SampleSolution 环境下 有 libcublas.so.11 是因为 它 安装了 cudatoolkit 11.1.1


# **SampleSolution** 环境 cudatoolkit     版本
conda list

cudatoolkit               11.1.1               h6406543_8    conda-forge


# 当前环境 cudatoolkit     版本
conda list

cudatoolkit               10.1.243             h6bb024c_0  


因此解决思路应该是,更新当前环境 cudatoolkit 到对应版本即可,例如

pip install cudatoolkit=1x.x.x  
# pip 安装失败,我选择使用 conda 进行安装
conda install cudatoolkit=1x.x.x  

追更于20210622

  • 今天又遇到该报错
ImportError: libcurand.so.10: cannot open shared object file: No such file or directory

解决方法

conda install cudatoolkit==10.1.243 

# 类似

conda install cudatoolkit==11.1.1

🚀 人生苦短,欢迎和墨理一起学AI


👋 一文学会深度学习环境搭建,下面这一篇就能帮助各位有效入门 👋

  • ❤️ 墨理学AI 博客尚有若干精品 干货专栏 、各位可按需查阅,感谢支持 ❤️

9-8

  • 13
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

墨理学AI

不必打赏,关注博主公众号即可

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

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

打赏作者

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

抵扣说明:

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

余额充值