How to verify CuDNN installation?
Installing CuDNN just involves placing the files in the CUDA directory. If you have specified the routes and the CuDNN option correctly while installing caffe it will be compiled with CuDNN.
You can check that using cmake
. Create a directory caffe/build
and run cmake ..
from there. If the configuration is correct you will see these lines:
-- Found cuDNN (include: /usr/local/cuda-7.0/include, library: /usr/local/cuda-7.0/lib64/libcudnn.so)
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_30
-- cuDNN : Yes
If everything is correct just run the make
orders to install caffe from there.
My answer shows how to check the version of CuDNN installed, which is usually something that you also want to verify. You first need to find the installed cudnn file and then parse this file. To find the file, you can use:
whereis cudnn.h
CUDNN_H_PATH=$(whereis cudnn.h)
If that doesn't work, see "Redhat distributions" below.
Once you find this location you can then do the following (replacing ${CUDNN_H_PATH}
with the path):
cat ${CUDNN_H_PATH} | grep CUDNN_MAJOR -A 2
The result should look something like this:
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 5
#define CUDNN_PATCHLEVEL 0
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
Which means the version is 7.5.0.
Ubuntu 18.04 (via sudo apt install nvidia-cuda-toolkit)
This method of installation installs cuda in /usr/include and /usr/lib/cuda/lib64, hence the file you need to look at is in /usr/include/cudnn.h.
CUDNN_H_PATH=/usr/include/cudnn.h
cat ${CUDNN_H_PATH} | grep CUDNN_MAJOR -A 2
Debian and Ubuntu
From CuDNN v5 onwards (at least when you install via sudo dpkg -i <library_name>.deb
packages), it looks like you might need to use the following:
cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
For example:
$ cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 6
#define CUDNN_MINOR 0
#define CUDNN_PATCHLEVEL 21
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
#include "driver_types.h"
indicates that CuDNN version 6.0.21 is installed.
Redhat distributions
On CentOS, I found the location of CUDA with:
$ whereis cuda
cuda: /usr/local/cuda
I then used the procedure about on the cudnn.h file that I found from this location:
$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
To check installation of CUDA, run below command, if it’s installed properly then below command will not throw any error and will print correct version of library.
function lib_installed() { /sbin/ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep $1; }
function check() { lib_installed $1 && echo "$1 is installed" || echo "ERROR: $1 is NOT installed"; }
check libcuda
check libcudart
To check installation of CuDNN, run below command, if CuDNN is installed properly then you will not get any error.
function lib_installed() { /sbin/ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep $1; }
function check() { lib_installed $1 && echo "$1 is installed" || echo "ERROR: $1 is NOT installed"; }
check libcudnn
OR
you can run below command from any directory
nvcc -V
it should give output something like this
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61
The installation of CuDNN is just copying some files. Hence to check if CuDNN is installed (and which version you have), you only need to check those files.
Install CuDNN
Step 1: Register an nvidia developer account and download cudnn here (about 80 MB). You might need nvcc --version
to get your cuda version.
Step 2: Check where your cuda installation is. For most people, it will be /usr/local/cuda/
. You can check it with which nvcc
.
Step 3: Copy the files:
$ cd folder/extracted/contents
$ sudo cp include/cudnn.h /usr/local/cuda/include
$ sudo cp lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
Check version
You might have to adjust the path. See step 2 of the installation.
$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
edit: In later versions this might be the following (credits to Aris)
$ cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
Notes
When you get an error like
F tensorflow/stream_executor/cuda/cuda_dnn.cc:427] could not set cudnn filter descriptor: CUDNN_STATUS_BAD_PARAM
with TensorFlow, you might consider using CuDNN v4 instead of v5.
Ubuntu users who installed it via apt
: https://askubuntu.com/a/767270/10425