Could not load dynamic library ‘libnvinfer.so.6‘

Could not load dynamic library ‘libnvinfer.so.6’

Ubuntu18.0 linux服务器上安装tensorflow-gpu运行import tnsorflow as tf时出错,提示如下:

2021-06-10 23:23:42.245584: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.1/lib64
2021-06-10 23:23:42.245639: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/cuda-10.1/lib64
2021-06-10 23:23:42.245662: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.

解决:
参考:https://stackoverflow.com/questions/60368298/could-not-load-dynamic-library-libnvinfer-so-6

# Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update

# Install NVIDIA driver
sudo apt-get install --no-install-recommends nvidia-driver-430
# Reboot. Check that GPUs are visible using the command: nvidia-smi

# Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
    cuda-10-1 \
    libcudnn7=7.6.4.38-1+cuda10.1  \
    libcudnn7-dev=7.6.4.38-1+cuda10.1

# Install TensorRT. Requires that libcudnn7 is installed above.
sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \
    libnvinfer-dev=6.0.1-1+cuda10.1 \
    libnvinfer-plugin6=6.0.1-1+cuda10.1

我的碎碎念:
权限:没有root权限,只有部分管理员权限,
过程描述:服务器上原本就安装有cuda-10.1和cuda-9.0,我需要用到的是cuda-10.1,把软连接换到cuda-10.1后,执行import tnsorflow as tf的时候报错,查到应该是缺失cudnn和tensorRT,用cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2查看服务器上是否安装cudnn,报错No such file or director,怀疑没有安装上cudnn或者路径不对,上网搜cudnn和tensorRT的安装方法,啊,贼麻烦,继续找其他办法。找到上述链接描述的问题,第一部分运行出错,怀疑是没有root权限或者说是因为已经安装有cuda,不需要了;第二部分,nvidia-smi查得驱动器版本是450,运行该命令,看结果应该是重装了(460—>450);第三部分,考虑到已经装了cuda,我把那一行去了,然后无脑继续。over~,解决。之后我再查看有没有安装cudnn,还是报错No such file or director真是神了奇了。(未解决,我放弃)

查看版本型号
(1)cuda
cat /usr/local/cuda/version.txt # 方式一
nvcc -V # 方式二
(2)cudann
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

你可能感兴趣的:(五花八门的bug,cuda)