Libcudnn_cnn_infer.so.8 library can not found

I’m using miniconda + wsl. I have instaled cudnn + cuda toolkit
when I run pytorch project

/home/icy/miniconda3/envs/torch_new/bin/python /home/icy/source/examples/mnist/main.py 
/home/icy/miniconda3/envs/torch_new/lib/python3.9/site-packages/torch/lib
True
/usr/local/cuda
Could not load library libcudnn_cnn_infer.so.8. Error: libcuda.so: cannot open shared object file: No such file or directory
Please make sure libcudnn_cnn_infer.so.8 is in your library path!
Aborted

but in my environment , the so library can be found

(base) icy@DESKTOP-1D9KUKI:~/source/examples/mnist$ ldconfig -p | grep libcudnn_cnn_infer.so
        libcudnn_cnn_infer.so.8 (libc6,x86-64) => /usr/local/cuda/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
        libcudnn_cnn_infer.so (libc6,x86-64) => /usr/local/cuda/targets/x86_64-linux/lib/libcudnn_cnn_infer.so

any idea how to solve this questions? or how pytorch is find cudnn lib

1 Like

Hi, I also faced the same problem on WSL2.

As discussed in this issue it is just a matter to add this in the .bashrc:

export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH

Be sure that your library is in /usr/lib/wsl/lib, to see it you can run

ldconfig -p | grep cuda
3 Likes

I have downgraded to Ubuntu20.04 wsl. this problem was gone. I think is related to Ubuntu 22.04
thanks for your helping by the way.

Hello @kcyrockton Do you solve the issue with ubuntu22.04? I have the same bug!

nope
I have downgraded to Ubuntu20.04

Thank you so much! It works

1 Like

Thanks! This worked for me on WSL2 with Ubuntu22.04 :slight_smile:

I had the same issue on Ubuntu 22.04.

The error message is a bit misleading:

Could not load library libcudnn_cnn_infer.so.8. Error: libcuda.so: cannot open shared object file: No such file or directory
Please make sure libcudnn_cnn_infer.so.8 is in your library path!

The problem is not libcudnn_cnn_infer.so.8 as the second line says, but as mentioned in the first line, libcudnn_cnn_infer.so.8 is trying to open libcuda.so that it cannot find.

On my distribution, I had a libcuda.so.1 but no libcuda.so. So I made a symbolic link from libcuda.so.1 to libcuda.so and it worked.

1 Like

Did you build PyTorch from source or did you install the pip wheels or conda binaries?
Also, did you see the issue only on WSL2?

In my case, I installed it with pip. And it is on a native Ubuntu 22.04 LTS (not WSL)

For me, I considered it as solved. But I just mentioned my solution in case that would be helpful.

I’m seeing a similar issue except I wouldn’t be able to use the recommended solution for downgrading to Ubuntu 22.04 since I’m on Debian bookworm. I do have LD_LIBRARY_PATH set to :/home/barry1/miniconda3/envs/tf/lib/ does anyone have any other recommendations?

fixed it using the solution here: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link · Issue #5663 · microsoft/WSL · GitHub

WSL is garbage. that is all.