python - "Could not load dynamic library ' libcudnn.so.8 '"在 ubuntu 20.04 上运行 tensorflow 时

标签 python tensorflow

注意:有许多类似的问题,但针对不同版本的 ubuntu 和有些不同的特定库。我一直无法弄清楚符号链接(symbolic link)的组合,附加环境变量,例如 LD_LIBRARY_PATH会工作
这是我的 nvidia 配置

$ nvidia-smi
Tue Apr  6 11:35:54 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.80.02    Driver Version: 450.80.02    CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce RTX 2070    Off  | 00000000:01:00.0 Off |                  N/A |
| 18%   25C    P8     9W / 175W |     25MiB /  7982MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1081      G   /usr/lib/xorg/Xorg                 20MiB |
|    0   N/A  N/A      1465      G   /usr/bin/gnome-shell                3MiB |
+-----------------------------------------------------------------------------+
运行 TF 程序时,发生了以下情况:
2021-04-06 14:35:01.589906: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
2021-04-06 14:35:01.589914: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
有没有人看到过这种特殊的组合,你是如何解决的?
这是尝试的其他修复之一,但没有变化:
conda install cudatoolkit=11.0

最佳答案

所以我有同样的问题。正如评论所说,这是因为您需要安装CUDNN。为此,有一个指南 here .
但是我已经知道你的发行版(Ubuntu 20.04)我已经可以给你命令行了:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
sudo apt-get install libcudnn8=${cudnn_version}-1+${cuda_version}
sudo apt-get install libcudnn8-dev=${cudnn_version}-1+${cuda_version}
哪里${cudnn_version}例如 8.2.4.*${cuda_version}例如 cuda11.0 (正如我所见,您在命令 nvidia-smi 上有 11.0,虽然我没有测试它,因为我的是 11.4,但我想它应该可以正常工作)

关于python - "Could not load dynamic library ' libcudnn.so.8 '"在 ubuntu 20.04 上运行 tensorflow 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66977227/

相关文章:

tensorflow - “KerasLayer”对象没有属性 'layers'

python - CNN : images and parameters, 的多个输入如何合并

python - 深度学习: save and load a universal machine model through different libraries

python - Tensorflow 2.0,将张量中的 0 值替换为 1s

python - scipy中通过mean和std对负二项式进行参数化

python - 在 Django 中设置拆卸登录注销的正确方法

python - 根据某些字符在python中拆分行

java - 如何在Python中影响内循环的外循环变量?

python - 重写discord.py |我怎样才能把它变成一个整数?

python - 导入错误: cannot import name bayesflow