Tensorflow: Cannot dlopen some GPU libraries. Skipping registering GPU devices...

Cannot dlopen some GPU libraries. Skipping registering GPU devices…

很久没搞Tensorflow了,又出了一些问题,这里作个备份

可能的问题为:

1,cuda和安装的tensorflow版本不对应

可参考:Tensorflow与cuda版本对应关系

2, 未成功加载cuda的动态库,可通过代码如下测试

import tensorflow as tf
tf.test.gpu_device_name()

如果出现如下错误:

2020-05-26 13:41:11.299037: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcudart.so.10.0'; dlerror: libcudart.so.10.0: cannot open shared object file: No such file or directory
2020-05-26 13:41:11.299176: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcublas.so.10.0'; dlerror: libcublas.so.10.0: cannot open shared object file: No such file or directory
2020-05-26 13:41:11.299257: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcufft.so.10.0'; dlerror: libcufft.so.10.0: cannot open shared object file: No such file or directory
2020-05-26 13:41:11.299336: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcurand.so.10.0'; dlerror: libcurand.so.10.0: cannot open shared object file: No such file or directory
2020-05-26 13:41:11.299413: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcusolver.so.10.0'; dlerror: libcusolver.so.10.0: cannot open shared object file: No such file or directory
2020-05-26 13:41:11.299490: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcusparse.so.10.0'; dlerror: libcusparse.so.10.0: cannot open shared object file: No such file or directory

可能是未配置 LD_LIBRARY_PATH

vim ~/.bashrc

打开 .bashrc 并在尾部添加如下代码(cuda版本改为你自己的,这里是9.2)

export LD_LIBRARY_PATH="/usr/local/cuda-9.2/lib64:$LD_LIBRARY_PATH" 

然后使其生效

source ~/.bashrc

3,其他可参考

tensorflow运行使用CPU不使用GPU

附:cudnn安装方法

sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
cd /usr/local/cuda/lib64
sudo ln -sf libcudnn.so.7.6.3 libcudnn.so.7
sudo ln -sf libcudnn.so.7 libcudnn.so
sudo ldconfig

参考:Ubuntu:安装cudnn10.1

你可能感兴趣的:(other,cuda,tensorflow,ubuntu,cudnn,dlopen)