Libcudnn_cnn_infer.so.8 library can not found

Icyrockton: <p>I’m using miniconda + wsl. I have instaled cudnn + cuda toolkit<br>
when I run pytorch project</p>
<pre><code class="lang-python">/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
</code></pre>
<p>but in my environment , the so library can be found</p>
<pre><code class="lang-python">(base) icy@DESKTOP-1D9KUKI:~/source/examples/mnist$ ldconfig -p | grep libcudnn_cnn_infer.so
        libcudnn_cnn_infer.so.8 (libc6,x86-64) =&gt; /usr/local/cuda/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
        libcudnn_cnn_infer.so (libc6,x86-64) =&gt; /usr/local/cuda/targets/x86_64-linux/lib/libcudnn_cnn_infer.so
</code></pre>
<p>any idea how to solve this questions?  or how pytorch is find cudnn lib</p>

ncovallero: <p>Hi, I also faced the same problem on WSL2.</p>
<p>As discussed in this <a href="https://github.com/microsoft/WSL/issues/8587" rel="noopener nofollow ugc">issue</a> it is just a matter to add this in the .bashrc:</p>
<pre><code class="lang-auto">export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
</code></pre>
<p>Be sure that your library is in /usr/lib/wsl/lib, to see it you can run</p>
<pre><code class="lang-auto">ldconfig -p | grep cuda
</code></pre>

Icyrockton: <p>I have downgraded to Ubuntu20.04 wsl. this problem was gone. I think is related to Ubuntu 22.04<br>
thanks for your helping by the way.</p>

robot-nano: <p>Hello <span class="mention">@kcyrockton</span> Do you solve the issue with ubuntu22.04? I have the same bug!</p>

Icyrockton: <p>nope<br>
I have downgraded to Ubuntu20.04</p>

zfb: <p>Thank you so much! It works</p>

bramgrooten: <p>Thanks! This worked for me on WSL2 with Ubuntu22.04 <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>

plebreton: <p>I had the same issue on Ubuntu 22.04.</p>
<p>The error message is a bit misleading:</p>
<pre><code class="lang-auto">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!
</code></pre>
<p>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.</p>
<p>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.</p>

ptrblck: <p>Did you build PyTorch from source or did you install the pip wheels or conda binaries?<br>
Also, did you see the issue only on WSL2?</p>

plebreton: <p>In my case, I installed it with pip. And it is on a native Ubuntu 22.04 LTS (not WSL)</p>
<p>For me, I considered it as solved. But I just mentioned my solution in case that would be helpful.</p>

barry1: <p>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 <code>:/home/barry1/miniconda3/envs/tf/lib/</code> does anyone have any other recommendations?</p>
<p>fixed it using the solution here: <a href="https://github.com/microsoft/WSL/issues/5663#issuecomment-1068499676" class="inline-onebox" rel="noopener nofollow ugc">/usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link · Issue #5663 · microsoft/WSL · GitHub</a></p>
<p>WSL is garbage. that is all.</p>

hohomi: <p>Thank you! It works. I have solved the issue under ubuntu 22.04.</p>

diegocaples: <p>worked with WSL2 on ubuntu 22.04 for me as well!</p>

luomin5417: <p>i have same problem，and i can’t find the libcudnn_cnn_infer.so.8 in the /usr/lib/wsl/lib</p>

hayesgb: <p>I encountered this on WSL2 as well.   Fixed by <a href="https://github.com/microsoft/WSL/issues/5663#issuecomment-1068499676" class="inline-onebox" rel="noopener nofollow ugc">/usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link · Issue #5663 · microsoft/WSL · GitHub</a></p>

lewiz: <p>Thanks pal, it solves the issue !</p>

Redev: <p>I had the same problem, none of the solutions here worked, in the end the problem was my shell since i was usign fish, tried every solution in this thread and then i just used bash and it worked</p>

zhangl1201: <p>also worked for me with WSL2, ubuntu 22.04</p>

binze_wang: <p>thank you, your answer solves my question!</p>

Dulshan_Madusanka: <p>Hey, thanks. this worked.</p>