简体   繁体   中英

How to install cuDNN in Ubuntu on WSL2?

I have encountered an issue running Tensorflow 2 on my Windows 10 (it only runs one epoch), so I am trying to install cuda and tensorflow 2 on Ubuntu via WSL2 instead.

I have followed this guide: https://ubuntu.com/tutorials/enabling-gpu-acceleration-on-ubuntu-on-wsl2-with-the-nvidia-cuda-platform#5-enjoy-ubuntu-on-wsl which is very similar to the Nvidia one here, only I have installed cuda version 11.4 instead of the latest cuda 11.7: https://docs.nvidia.com/cuda/wsl-user-guide/index.html#installing-wsl2

I am stuck if I need to install cuDNN after this and what version. Windows or Linux in my case ( https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html )?

when I run my notebook, I get the following issue, which shows cuDNN is missing:

> 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.

Please advise?

that said, I had an nvidia driver/cuda/cudnn/tensorflow 2 compatible setup installed directly on Windows but one day I had an issue with some of my models' training (my other stackoverflow post). Thank you very much.

I can't tell you exactly what to do but you can do this in wsl to find the library:

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

then use the path you find and set environment variable:

export LD_LIBRARY_PATH=<PATH_OF_LIBRARY_FROM_ABOVE_CODE>:$LD_LIBRARY_PATH

that was the thing that I did to make it work BTW I installed cudnn and cudatoolkit using conda:

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

PS:to make you changes persistent you can add export to .bashrc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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