Skip to content

Instantly share code, notes, and snippets.

@akaanirban
Last active December 4, 2020 18:50
Show Gist options
  • Save akaanirban/a8891a447cf0e578d86331555499ed62 to your computer and use it in GitHub Desktop.
Save akaanirban/a8891a447cf0e578d86331555499ed62 to your computer and use it in GitHub Desktop.
How to get rid of the `Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory;` problem

Basically this error is due to the fact that libcudnn*.so files are not present in the installation path of cuda. It appears that on installing the cuda toolkit, the cudnn files are not by default installed. Now the installation path of cuda varies in different machines/installations for example it can be /usr/local/cuda/lib64 , but also in some cases can be /usr/lib/cuda/lib64/ etc.

  1. Anyway, where ever the installation path maybe, you can find it out by doing whereis cuda.
  2. Once that is done, then you need to download the specific cuda version of cuDNN Library for Linux from Nvidias website: https://developer.nvidia.com/cudnn . Here in the following I download and install cuDNN for cuda 10.1.

Version 7 (libcudnn.so.7) can be directly downloaded as

wget https://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.1_20191031/cudnn-10.1-linux-x64-v7.6.5.32.tgz?m2hqDRAYQiO6rrilch-TIU9xtf877-R5k-aUI4GXEShM3FY3Sap9Ua4wTj5LUxyQAED2lrSf2NSWhuEn-tQCvEDghZ4f7YUlpKkCq5vTnEXANl9ooqQ6khAZSABike1TaAtw0eKv9njKcy2MZYTSOhmtwdbA9sxe6OlLnm2aP-B8A9XAIFNoFwAmvhwaom2wyNdK2cfJ0je0keQSdHXKat72DEUI4Rpdiw
mv cudnn-10.1-linux-x64-v7.6.5.32.tgz\?m2hqDRAYQiO6rrilch-TIU9xtf877-R5k-aUI4GXEShM3FY3Sap9Ua4wTj5LUxyQAED2lrSf2NSWhuEn-tQCvEDghZ4f7YUlpKkCq5vTnEXANl9ooqQ6khAZSABike1TaAtw0eKv9njKcy2MZYTSOhmtwdbA9sxe6OlLnm2aP-B8A9XAIFNoFwAmvhwaom2wyNdK2cfJ0 cudnn-10.1-linux-x64-v7.6.5.32.tgz

Version 8 (libcudnn.so.8) can be also be directly downloaded as

wget https://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/8.0.5/10.1_20201106/cudnn-10.1-linux-x64-v8.0.5.39.tgz?Usq9mE_Lga0aPT_LueQ-JBpaGOx4qJgy0IzatNF5-ckT2Gat4otxsR88R8kDchN25p4-WUqXP1bLVM54YxAohkczfbGsbs87HIGnsl9fVHILaSbvF8p7ztzFVtaR_jj243gqIkr5IkHDuZvcN8vInVADmTuf9897exXIoqDhGyro-_HbQK9dLoZbsGmWtRLeYPaQsdLCh0UieXk
mv cudnn-10.1-linux-x64-v8.0.5.39.tgz\?Usq9mE_Lga0aPT_LueQ-JBpaGOx4qJgy0IzatNF5-ckT2Gat4otxsR88R8kDchN25p4-WUqXP1bLVM54YxAohkczfbGsbs87HIGnsl9fVHILaSbvF8p7ztzFVtaR_jj243gqIkr5IkHDuZvcN8vInVADmTuf9897exXIoqDhGyro-_HbQK9dLoZbsGmWtRLeYPaQsdLCh cudnn-10.1-linux-x64-v8.0.5.39.tgz
  1. Extract using tar -xvzf cudnn-10.1-linux-x64-v7.6.5.32.tgz assuming we want to install libcudnn.so.7
  2. Install the files, by basically copying them in the cuda installation location in step 1. We assume that the cuda toolkit installed in /usr/local/cuda/*
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
  1. Set permission to executable
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Then test the output. Open a python3 prompt and do the following:

import tensorflow as tf
tf.test.is_gpu_available()

If everything is successful, then this should give you a True at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment