Barry Rosenberg
Barry Rosenberg

Reputation: 2227

ImportError: libcudnn when running a TensorFlow program

I encountered the following error when trying to run a TensorFlow program:

ImportError: libcudnn.Version: cannot open shared object file: No such file or director

Upvotes: 27

Views: 42631

Answers (8)

Moustafa Abdelhamid
Moustafa Abdelhamid

Reputation: 56

Download and install cuDNN from https://developer.nvidia.com/rdp/cudnn-download

for ubuntu 18.04 and cuda 10.1:

sudo dpkg -i libcudnn7_7.5.0.56-1+cuda10.1_amd64.deb

Upvotes: 1

Ankit Kumar
Ankit Kumar

Reputation: 1785

Just download cuDNN 5.1 and follow the steps (Tested on Ubuntu 16.04, CUDA toolkit 8.0 )

$ tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
$ sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Now set Path variables

$ vim ~/.bashrc

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

and done

For more details, you can check this site

Upvotes: 39

Kevin Dewalt
Kevin Dewalt

Reputation: 777

It appears TensorFlow now supports cudNN 6.0. I was getting errors with cudNN 5.1.

Using TensorFlow version 1.3.0.

If you're getting

ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory

Try using 6.0

Upvotes: 10

Taylor Eisman
Taylor Eisman

Reputation: 11

I was able to solve problem by changing my cudNN installation from cudNN 6.0 to cudNN 5.1. cudNN 6.0 has the file libcudnn.so.6 while cudNN 5.1 has the file libcudnn.so.5.

Upvotes: 1

Aditya
Aditya

Reputation: 553

I faced this issue. In my case my eclipse gave this error but tensorflow was running smoothly in terminal. So after cuDNN installation or pasting the files related to cudNN in /usr/local/cuda/lib64 and /usr/local/cuda/include, I figured that the command sudo ldconfig -v also has to be executed in the terminal.

After that it should work.

This is assuming that one has already set the following environment variables as per the specifications in CUDA installation procedure by NVIDIA: LD_LIBRARY_PATH, PATH, CUDA_HOME

Upvotes: 4

Thor Mortensen
Thor Mortensen

Reputation: 33

Make sure the $LD_LIBRARY_PATH environment variable is set to the correct path.

From the cuDNN Install Guide:

ALL PLATFORMS

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

LINUX

cd <installpath>
export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH

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

OS X

cd <installpath>
export DYLD_LIBRARY_PATH=`pwd`:$DYLD_LIBRARY_PATH

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

WINDOWS

Add <installpath> to the PATH environment variable.

In your Visual Studio project properties, add <installpath> to the Include Directories 
and Library Directories lists and add cudnn.lib to Linker->Input->Additional Dependencies.

Upvotes: 2

mmdanziger
mmdanziger

Reputation: 4658

At this time Tensorflow does not support cuDNN 6. If your error is that it cannot find libcudnn.so.5 and you have only installed cuDNN 6 which provides libcudnn.so.6, you'll have to install cuDNN 5 until cuDNN 6 support is introduced. There's an open bug report that you can follow on the Tensorflow Github page to find out when they start supporting cuDNN 6.

Upvotes: 6

Barry Rosenberg
Barry Rosenberg

Reputation: 2227

You may not have installed the correct version of cuDNN.

To determine the correct version of cuDNN, see the NVIDIA requirements to run TensorFlow with GPU support.

Upvotes: 2

Related Questions