Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory #8

Closed
srepho opened this issue Mar 20, 2015 · 21 comments

Comments

@srepho
Copy link

srepho commented Mar 20, 2015

I have followed the steps exactly as in your guide using an Amazon AWS GPU instance. When I get to the running of the .\digit-server I get:

Cannot guess value for "caffe_root": caffe binary cannot be found
Cannot guess value for "gpu_list": Cannot query GPUs without a valid caffe_root

I also tried to download the .tar but when I run the ./runme file and I get

ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory

Do you have any suggestions about what I am doing wrong?

@lukeyeager
Copy link
Member

Two suggestions:

  1. You should use digits-devserver instead of digits-server. The devserver runs a user-level application, so you don't need root permissions for anything. This will also give you an interactive prompt for setting the configuration options.
  2. Both of your issues seem to be regarding environment variables. You probably need to add these two lines to your .bashrc (but customized to match the installation on your machine, of course):
export CAFFE_ROOT=/home/username/caffe
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

@srepho
Copy link
Author

srepho commented Mar 21, 2015

Thanks so much - this has solved the issue.

@Saneesh
Copy link

Saneesh commented Jul 10, 2015

For this error
ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory

I have executed this command to solve it
sudo ldconfig /usr/local/cuda/lib64

@lakartoza
Copy link

@Saneesh Thank you! Solved mine

@lukeyeager
Copy link
Member

For those of you on Ubuntu 14.04 who have installed CUDA 7.0 or 7.5 with a .deb package, you can now solve this problem by installing the cuda-ld-conf-7-0 package (or cuda-ld-conf-7-5, if you like).

$ apt-cache show cuda-ld-conf-7-0
Package: cuda-ld-conf-7-0
Depends: cuda-cudart-7-0, cuda-cublas-7-0, cuda-curand-7-0, cuda-license-7-0
Description: CUDA ld.so.conf files
 With this package, your programs will be able to find the CUDA shared
 libraries without editing the LD_LIBRARY_PATH environment variable.

You can follow these instructions to get access to the repository that contains these packages.

@lukeyeager
Copy link
Member

For more information, please see the "Environment" section of docs/InstallCuda.md.

@lukeyeager lukeyeager changed the title ImportError:libcurart.so.7.0: cannot open shared object file: No such file or directory ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory Mar 10, 2016
@ParitoshParmar
Copy link

@Saneesh this is one of those life saving tips. Thanks a ton!

@ranju2015
Copy link

@Saneesh Many Thanks. Solved my problem.

@NickShargan
Copy link

@Saneesh Thanks a lot. When I run sudo ldconfig /usr/local/cuda/lib (not for lib64) it became work.

@chrisranderson
Copy link

In case someone else runs into this... I got an error (something about libcudnn.so is not a symbolic link or something) when trying ldconfig. My directory looked like this:

screenshot from 2016-10-07 07-38-55

See how the libcudnn.so files are duplicated instead of linked like the others? I deleted the first two, and then made it a chain of symbolic links like so:

sudo rm libcudnn.so
sudo rm libcudnn.so.5
sudo ln -s libcudnn.so.5.0.5 libcudnn.so.5
sudo ln -s libcudnn.so.5 libcudnn.so

I actually came here in search of fixing a TensorFlow problem - this ended up fixing it.

@lukeyeager
Copy link
Member

@chrisranderson if you installed cuDNN with a deb package instead of with a tarball then you wouldn't run into this issue.

@chrisranderson
Copy link

chrisranderson commented Oct 11, 2016

@lukeyeager how do I do that? (I'm in Ubuntu 16.04 if that matters)

@gheinrich
Copy link
Contributor

@chrisranderson have a look at the CUDA install doc.

@xnmp
Copy link

xnmp commented Nov 6, 2016

@Saneesh Bloody legend

@codeAshu
Copy link

Same case is with cuDNN 5.1. Follow the solution of @chrisranderson

@data-scientist-ml1
Copy link

data-scientist-ml1 commented Aug 1, 2017

thanks @Saneesh your solution saved my life with matconvnet

@famishedrover
Copy link

I have import error: ImportError: libcudnn.so.7: cannot open shared object file: No such file or directory
with CUDA 9.0
Tensorflow 1.5

download https://developer.nvidia.com/rdp/cudnn-download 7.0.5 for cuda 9.0
sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*

cd
cd cuda

sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/lib* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64/
sudo chmod +r libcudnn.so.7.0.5
sudo ln -sf libcudnn.so.7.0.5 libcudnn.so.7
sudo ln -sf libcudnn.so.7 libcudnn.so
sudo ldconfig
It works for me.

@SAGGSOC
Copy link

SAGGSOC commented Mar 23, 2018

sagar@sagar-HP-Pavilion-Notebook:~/caffe2/caffe2/python/examples$ python char_rnn.py --train_data shakespeare.txt
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: libcudnn.so.7: cannot open shared object file: No such file or directory
Segmentation fault (core dumped)
How to solve this error?

@somsanithx
Copy link

when I run the code this message appear anyone can help me please, i'm new in python and I try to learn DL ML and AI application tool.

Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)])
File "C:\Users\Somsanith_s\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python_init_.py", line 54, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Somsanith_s/PycharmProjects/MytestDec118/App_mytest.py", line 401, in
from keras.models import Sequential
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\keras_init_.py", line 3, in
from . import utils
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\keras\utils_init_.py", line 6, in
from . import conv_utils
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\keras\utils\conv_utils.py", line 9, in
from .. import backend as K
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\keras\backend_init_.py", line 89, in
from .tensorflow_backend import *
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in
import tensorflow as tf
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python_init_.py", line 60, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(file)])
File "C:\Users\Somsanith_s\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python_init_.py", line 54, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\Somsanith_s\PycharmProjects\MytestDec118\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'

Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.

@somsanithx
Copy link

the important is " Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there."

@englianhu
Copy link

:~$ sudo apt-get install libcudnn*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libcudnn-dev' for glob 'libcudnn*'
Note, selecting 'libcudnn8-dev' for glob 'libcudnn*'
Note, selecting 'libcudnn7' for glob 'libcudnn*'
Note, selecting 'libcudnn8' for glob 'libcudnn*'
libcudnn8 is already the newest version (8.2.0.53-1+cuda11.3).
libcudnn-dev is already the newest version (7.6.5-0lambda1).
libcudnn7 is already the newest version (7.6.5-0lambda1).
The following packages were automatically installed and are no longer required:
  ledit libfindlib-ocaml libfindlib-ocaml-dev libldap2-dev ocaml-compiler-libs ocaml-findlib
  ocaml-interp ocaml-man ocaml-nox wine-stable wine-stable-amd64 wine-stable-i386:i386
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  libcudnn8-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/582 MB of archives.
After this operation, 2,570 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 448004 files and directories currently installed.)
Preparing to unpack .../libcudnn8-dev_8.2.0.53-1+cuda11.3_amd64.deb ...
Unpacking libcudnn8-dev (8.2.0.53-1+cuda11.3) ...
dpkg: error processing archive /var/cache/apt/archives/libcudnn8-dev_8.2.0.53-1+cuda11.3_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libcudnn_static.a', which is also in package libcudnn-dev:amd64 7.6.5-0lambda1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libcudnn8-dev_8.2.0.53-1+cuda11.3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

and then

x [master]> use_condaenv("tf")
✓ [master]> library(tensorflow)
✓ [master]> hello <- tf$constant('Hello, TensorFlow!')
Error: Python module tensorflow was not found.

Detected Python configuration:

python:         /home/englianhu/anaconda3/bin/python3
libpython:      /home/englianhu/anaconda3/lib/libpython3.8.so
pythonhome:     /home/englianhu/anaconda3:/home/englianhu/anaconda3
version:        3.8.10 (default, May 19 2021, 18:05:58)  [GCC 7.3.0]
numpy:          /home/englianhu/.local/lib/python3.8/site-packages/numpy
numpy_version:  1.19.5
tensorflow:     /home/englianhu/.local/lib/python3.8/site-packages/tensorflow

NOTE: Python version was forced by RETICULATE_PYTHON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests