【无标题】

解决tf不能使用GPU加速的问题Could not load dynamic library ‘libcudart.so.10.1’; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory Could not load dynamic library ‘libcudnn.so.7’; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory

跑强化学习代码时,想使用GPU加速,但是报了如下错误:

RuntimeError: GPUs were assigned to this worker by Ray, but your DL framework (tf) reports GPU acceleration is disabled. This could be due to a bad CUDA- or tf installation.

百度后,发现是可能cuda安装时出了问题.
首先查看tensorflow是否能使用GPU

import tensorflow as tf
tf.test.is_gpu_available()

再输入上述第一条指令时,报错

 Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory

第二条指令报错

Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory

解决方法

echo $LD_LIBRARY_PATH

我的是/usr/local/cuda/lib64

cd /usr/local/cuda/lib64

使用ll指令查看,发现只有libcuda.so.10.2和libcudnn.so.8,
故建立相关软连接

sudo ln -s /usr/local/cuda/lib64/libcudart.so.10.2 /usr/local/cuda/lib64/libcudart.so.10.1
sudo ln -s /usr/local/cuda/lib64/libcudnn.so.8 /usr/local/cuda/lib64/libcudnn.so.7

最终问题解决!

你可能感兴趣的:(python,tensorflow,开发语言)