Machine Learning with GPU (2): cuDNN

ade sueb
Jul 31, 2020

--

If you working with Machine Learning using GPU this story is the answer. But before you continue to read this story, please read story : Machine Learning with GPU (1) : CUDA

“The NVIDIA CUDA® Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers. (source: nvidia.com)

Checking…

This script is for checking num of gpu available using tensorflow.

import tensorflow as tfprint("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

should return :

Num GPUs Available:  1

At least 1,

If you run script above, and you got this error :

Ubuntu 20.04 NVDIA cuda Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7

So you need to install cuDNN.

Download cuDNN

You can download cuDNN from this link. You need to login if you want to download. Don’t worry, just login or register, it’s easy and free.. After open the link, choose this:

Extract and Copy

copy to the cuda folder. If you use ubuntu 20.04 :

sudo cp cuda/include/cudnn.h /usr/lib/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/lib/cuda/lib64/

add read permission to both these target directory

sudo chmod a+r /usr/lib/cuda/include/cudnn.h /usr/lib/cuda/lib64/libcudnn*

Symlink libcudnn.so.7

do symlink libcudnn.so.7 to this folder, to make libcudnn recognizable to tensorflow or some apps :

sudo ln -s /usr/lib/cuda/lib64/libcudnn.so.7 /usr/lib/x86_64-linux-gnu/libcudnn.so.7

Re run the script

import tensorflow as tfprint("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

and now should return :

Num GPUs Available:  1

At least 1,,

--

--