繁体   English   中英

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

[英]How to install cuDNN in Ubuntu on WSL2?

我在 Windows 10 上运行 Tensorflow 2 时遇到了问题(它只运行一个 epoch),所以我尝试通过 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...
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.

请指教?

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

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

sudo find / -name 'libcudnn.so.8'

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

export LD_LIBRARY_PATH=<PATH_OF_LIBRARY_FROM_ABOVE_CODE>:$LD_LIBRARY_PATH

这就是我为使其正常工作所做的事情顺便说一句,我使用 conda 安装了 cudnn 和 cudatoolkit:

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM