Machine Learning with GPU (2): cuDNN

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,,

--

--

--

Still believe, can change the world with code..

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Understanding the flow of information through GRU cell

Example of Denoising Dirty Documents with AutoEncoders

Explainable AI: Building more trusted and valuable AI solutions

Writing a ML model that learns how to play Atari games.

Deep Learning on a Budget: $450 eGPU vs Google Colab

Forecasting News Coverage

Semantic Analysis of Footnotes using Extractive Summarization

Counting Squats with a Simple Convolutional Neural Network

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ade sueb

ade sueb

Still believe, can change the world with code..

More from Medium

From scratch to CUDA installation and TensorFlow compilation from the sources on Ubuntu 20.04

Estimate PSF from blurred and unblurred images.

Step by step guide to setup Tensorflow with GPU support on windows 10

Adding Type Hints to Pytorch __call__ function