7

the cuDNN installation manual says

ALL PLATFORMS

Extract the cuDNN archive to a directory of your choice, referred to below as . Then follow the platform-specific instructions as follows.

LINUX

cd export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH

Add to your build and link process by adding -I to your compile line and -L -lcudnn to your link line.

It seems that it simply adds pwd to LD_LIBRARY_PATH, so I guess just replacing the files in pwd will do the update.

But it seems not that simple as after I've done this I got a complaint from Theano saying

cuDNN Version is too old. Update to v5, was 3007.

dontloo
  • 10,067
  • 4
  • 29
  • 50

3 Answers3

10
  1. replace cudnn.h in dir/cuda/include/
  2. remove the old library files in dir/cuda/lib64/
  3. add new library files to dir/cuda/lib64/
dontloo
  • 10,067
  • 4
  • 29
  • 50
9

I wrote a script which can be used to clean install a version of cuDNN or change the existing cuDNN to an older/a newer version. You can download the script from:

https://github.com/dnzzcn/cuDNNv

This is what the script does:

#!/bin/bash

rm -f /usr/include/cudnn.h
rm -f /usr/lib/x86_64-linux-gnu/*libcudnn*
rm -f /usr/local/cuda-*/lib64/*libcudnn*


cp -P packages/cudnn/include/cudnn.h /usr/include
cp -P packages/cudnn/lib64/libcudnn* /usr/lib/x86_64-linux-gnu/
chmod a+r /usr/lib/x86_64-linux-gnu/libcudnn*

rm -rf packages/cudnn

It performs the installation operations automatically for the version you need.

dnzzcn
  • 153
  • 1
  • 3
  • 11
  • assuming `packages/` is in your `CWD`? also requires `sudo`? – Shai Sep 13 '17 at 13:30
  • 1
    Yes, packages folder is included in the repository directory. There is a python script that calls the bash script above for the desired cuDNN version; and although I'm not sure, it should work without sudo. – dnzzcn Sep 14 '17 at 07:53
  • your application shows it has done the thing even when it hasn't. – deadcode Apr 16 '18 at 05:27
  • deadcode can you check terminal output when you try to install cuDNN? If you see errors regarding permissions, try running cuDNNv with sudo. – dnzzcn May 25 '18 at 07:35
7

This is an old question, but now we have conda. We don't need to manually replace these files anymore. conda install cudnn does all the trick.

youkaichao
  • 1,938
  • 1
  • 14
  • 26
  • 1
    This installed `cudnn` latest version `8.2.1.32` in the conda environment. However, when I run `cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2`, it still shows me version `7.5.1`. Any comments? – kkgarg Aug 09 '21 at 18:08
  • /usr/local/cuda/include/cudnn.h is not the cudnn version conda installs. Conda installs cudnn to its local path, for example /path/to/conda/envs/env_name/lib . It works by changing the rpath in the binary file. You can read the blog post https://zhuanlan.zhihu.com/p/101027069 if you can read Chinese. – youkaichao Aug 10 '21 at 02:39
  • How to install the latest minor version of a specifi major version (e.g 8.1)? – liang Sep 18 '21 at 04:17
  • @liang `conda install -c conda-forge cudnn=8.1` – Diego Chinellato May 18 '22 at 09:35