如何解决tensorflow2版本无法使用cuda-gpu加速的情况,如Could not load dynamic library ‘libcudart.so.10.1’ 等问题
我尝试了很多方法,发现方法2更省时省力。
[En]
I have tried many methods and found that method 2 is more time-saving and labor-saving.
场景描述
版本环境:
Ubuntu18版本
python3.8
tensorflow2.3版本
cuda 10.2
只要以上版本不是跨模型的,建议使用方法二求解!
[En]
As long as the above version is not across a model, it is recommended to use method 2 to solve!
测试脚本
import tensorflow as tf
tf.test.is_gpu_available()
输出结果:
返回错误报告
总的来说,就是找不到这些个文件了!!
2021-12-05 12:59:40.038419: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.0/lib64:
2021-12-05 12:59:40.038474: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.0/lib64:
2021-12-05 12:59:40.038518: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.0/lib64:
2021-12-05 12:59:40.038562: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.0/lib64:
2021-12-05 12:59:40.038605: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.0/lib64:
2021-12-05 12:59:40.038646: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcusparse.so.10'; dlerror: libcusparse.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.0/lib64:
图片:
尝试解决方法:
1. 重新安装 cuda 和 cuda驱动
重新安装需要慎重!!
安装的时候不能让你的gpu处于在运行状态!!!本人安装失败就是因为这个原因!!
安装链接: https://positive.blog.csdn.net/article/details/118080925
tensorflow版本和cuda版本对应的参考网址:
https://www.tensorflow.org/install/source_windows
如果你无法打开上面的连接,你也可以直接查看下面的图片。
[En]
If you can’t open the connection above, you can also check the following picture directly.
; 2. 不重装解决策略
– step1. 找到报错提示:并且发现之前安装cuda的默认路径,进入该路径内,在界面中输入:
cd /usr/local/cuda-10.0/lib64
– step 2. 对需要的文件进行复制!!! 将只有版本编号不同的报错的文件进行复制!!
sudo cp libcudart.so.10.0 libcudart.so.10.1
– step 3. 安装以上的操作方法对其他文件进行操作
sudo cp libcufft.so.10.0 libcufft.so.10
sudo cp libcurand.so.10.0 libcurand.so.10
sudo cp libcusolver.so.10.0 libcusolver.so.10
sudo cp libcusparse.so.10.0 libcusparse.so.10
注意:
最好是一条一条执行
最好是把报错文件进行查看,以便复制成对应的版本
结果展示
Original: https://blog.csdn.net/qsx123432/article/details/121728461
Author: 小王做笔记
Title: linux-Ubuntu系统下,tf无法使用gpu加速,如Could not load dynamic library ‘libcudart.so.10.1‘等问题
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/512010/
转载文章受原作者版权保护。转载请注明原作者出处!