如何在 WSL2 上的 Ubuntu 中安装 cuDNN?

Blu*_*ail 6 ubuntu python-3.x tensorflow

我在 Windows 10 上运行 Tensorflow 2 时遇到了问题(它只运行一个时期),因此我尝试通过 WSL2 在 Ubuntu 上安装 cuda 和 tensorflow 2。

我已遵循本指南: https ://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#5-enjoy-ubuntu-on-wsl与此处的 Nvidia 非常相似,只是我安装了 cuda 版本 11.4 而不是最新的 cuda 11.7: https://docs.nvidia.com/cuda/wsl-user-guide/index.html#installing-wsl2

如果我需要在此之后安装 cuDNN 以及什么版本,我会陷入困境。就我而言,是 Windows 还是 Linux(https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html)?

当我运行笔记本时,出现以下问题,表明 cuDNN 丢失:

> physical_devices = tf.config.list_physical_devices('GPU')
> physical_devices
> 2022-06-03 18:30:28.966198: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
> 2022-06-03 18:30:28.966233: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] 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...
Run Code Online (Sandbox Code Playgroud)
My specs:
Ubuntu 20.04 via WSL2
Windows 10 21H2
Nvidia latest driver, 512.95 compatible with GeForce RTX 3060
Cuda Driver Version/ Runtime Version 11.6/11.4( can update this to 11.7?)
Tensorflow 2.9.1
Python 3.9.7.
Run Code Online (Sandbox Code Playgroud)

请指教?

也就是说,我直接在 Windows 上安装了 nvidia 驱动程序/cuda/cudnn/tensorflow 2 兼容设置,但有一天我的一些模型训练出现了问题(我的另一篇 stackoverflow 帖子)。非常感谢。

Mah*_*ana 8

我无法确切地告诉你该怎么做,但你可以在 wsl 中执行此操作来查找库:

sudo find / -name 'libcudnn.so.8'
Run Code Online (Sandbox Code Playgroud)

然后使用您找到的路径并设置环境变量:

export LD_LIBRARY_PATH=<PATH_OF_LIBRARY_FROM_ABOVE_CODE>:$LD_LIBRARY_PATH
Run Code Online (Sandbox Code Playgroud)

这就是我为了让它工作而做的事情顺便说一句,我使用 conda 安装了 cudnn 和 cudatoolkit:

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
Run Code Online (Sandbox Code Playgroud)

PS:为了使更改持久,您可以将导出添加到 .bashrc