PyTorch cuDNN version mismatch: PyTorch was compiled against 7104 but linked against 7005

hasakii: <p>PyTorch remains so many bugs, feeling tired to use this framework…</p>
<p>So, the problem is, I compiled pytorch from source, and set CUDNN to my own path,<br>
there is nowhere exist another CUDNN or CUDA.</p>
<p>In the building log, <code>cuDNN version : 7.1.4</code>, but when I run lstm, it given following error:<br>
<code>RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7104 but linked against 7005</code>.</p>
<p>So, can anyone help me ??</p>

hasakii: <p>and, after build finished, I get the following warning:<br>
<code>warning: no library file corresponding to '/mnt/lustre/sjtu/users/mkh96/tools/cuda-9.0/lib64/libcudnn.so' found (skipping)</code></p>

albanD: <p>Hi,</p>
<p>Could you provide the following informations please:</p>
<ul>
<li>Where is your cuda install? Is there both one global and one local? like <code>/usr/local/cuda</code> and <code>/your/loca/cuda/</code> ?</li>
<li>What is the content of the <code>lib64</code> folder in it (or each install if you have more than one). Especially all the <code>ls -la libcudnn*</code> files?</li>
<li>What is the result of <code>echo $LD_LIBRARY_PATH</code> ?</li>
</ul>

hasakii: <p>Thanks for your advise. I checked all the environment path, I’m pretty sure that I used the same CUDNN dir which is version 7.1.4 and I also build other frameworks with this path.</p>
<p>Following is the warning log I found:</p>
<pre><code class="lang-auto">CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:1836 (add_library):
Cannot generate a safe runtime search path for target caffe2_gpu because
files in some directories may conflict with libraries in implicit 
directories: 

runtime library [libcudnn.so.7] in /mnt/lustre/sjtu/users/mkh96/tools/cuda-9.0/lib64 may be hidden by files in: 

/users/xxx/miniconda3/envs/pytorch/lib

Some of these libraries may not be found correctly.
Call Stack (most recent call first):
cmake/public/utils.cmake:134 (cuda_add_library) 
caffe2/CMakeLists.txt:227 (torch_cuda_based_add_library)
-- Generating done

CMake Warning:
 Manually-specified variables were not used by the project:   
CUDNN_LIB_DIR
</code></pre>
<p>Above was part of the problem building log, <strong>/users/xxx/miniconda3/envs/pytorch/lib</strong> is my pytorch conda dir.<br>
I use this python to compile pytorch source, but for Gods sake, I DO set CUDNN_LIB_DIR to another dir, because I have mxnet, tensorflow, kaldi, and so many frameworkds to use, all of them share a common environment path.</p>
<p>So, it’s my fault, I didn’t check the log carefully, I should not skip any warnings.</p>
<p>But I still want to mention: Why not use user set environment but search a confused dir ?<br>
User set environment should be the first order, but in the log, the program didn’t take it.<br>
This makes us can not trust your framework, we don’t know when or how some errors or bugs occur, and we would be really confused about those things, waste so many time.</p>
<p>I hope you considering it.</p>

hasakii: <p>By the way, I set <code>export PATH=$HOME/miniconda3/envs/pytorch/bin:$PATH</code> before run <code>python setup.py install</code></p>

albanD: <p>Hi,</p>
<p>If this folder is ahead in your LD_LIBRARY path, that means that the conda env is active right?<br>
Also you’re not supposed to add conda env bin to the path by hand ? I don’t use it so I’m not sure. But from what I remember, activating the env would do it for you (and handle the libraries properly as well).</p>
<p>The <code>CUDNN_LIB_DIR</code> is used at compile time, this is why you get pytorch compiled for cudnn 7.1. At runtime, the cudnn binary is loaded from shared library to reduce binary size and more flexibility. The warning printed at compile time is here to notify you if the cudnn that is going to be loaded (according to LD_LIBRARY_PATH) is the same as the one used for compilation.</p>

hasakii: <p>Thank you very much !</p>

Zhen_Cao: <p>Hi albanD.</p>
<p>I encountered a similar issue “RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7600”</p>
<p>How I understand this problem is that my code is compiled for cudnn 7.1.2  but try to run with cudnn 7.6.0. (Pls correct me if I am wrong) from your discussion.</p>
<p>I still haven’t solve this problem yet after referring to your discussion.<br>
May I know more background knowledge like why you ask that three quesitons?</p>
<p>For my case:<br>
I try to run my code under conda vitural env in a Ubuntu docker container.<br>
In addition, I checked I have “/usr/local/cuda” but I am not sure if I also have in my local ptath(how can i check?).  And I got both “cuda” and “cuda-9.0” in the folder “/usr/local/”. What’s this mean?</p>
<p>Content of the /usr/local/cuda/lib64 folder:  “ls: cannot access ‘libcudnn*’: No such file or directory”. The same to cuda-9.0.</p>
<p>echo $LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64</p>
<p>Thank you.</p>

Zhen_Cao: <p>Hi Hasakii,</p>
<p>How can you find the building log?</p>
<p>Thx</p>

albanD: <p>Hi,</p>
<p>I am not a conda expert but I think conda cudnn package is where you get your cudnn? Make sure that whatever this path is is properly linked to in the env variables? Also you can use “locate libcudnn.so” to find all the versions of cudnn on your system. Finally make sure to properly uninstall pytorch before installing from source as a binary install with an old cudnn might be hiding your source install.</p>

tyoc213: <p>ALso you can search for old installations like this <code>find . -name libcudnn* 2&gt;/dev/null </code></p>
<p>For example I was having results for</p>
<ul>
<li><code>find . -name libcudnn*8.0.5* 2&gt;/dev/null </code></li>
<li><code>find . -name libcudnn*8.1.0* 2&gt;/dev/null </code></li>
</ul>
<p>Then I just <code>rm -R /usr/local/cuda-11.1.0</code> and let <code>11.2.0</code> and it found the correct library.</p>