ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory when installing tensor flow on Ubuntu 16.04.03

14,173

Solution 1

This is almost always a missing path in your LD_LIBRARY_PATH. Find libcublas.so.9.0 on your system (start looking under /usr/local).

If you don't find it, then install the CUDA 9.0 Toolkit (note that with TF 1.5 you want 9.0 and not 9.1, a common gotcha, at least common in-so-far as I made that mistake myself).

https://developer.nvidia.com/cuda-90-download-archive

If you have it, then update your LD_LIBRARY_PATH to point to the appropriate lib directory.

If you've done either of those and are now getting a similar looking error for a cudnn related library, then repeat that process for the CUDNN library.

https://developer.nvidia.com/cudnn

I think the latest version works. Tensorflow depends on both CUDA toolkit and the CuDNN library extension.

Note that you can install all of this in userspace too (sudo is typical, but not required).

Solution 2

To easily find the libcublas file, run sudo find / -iname 'libcublas*'. Then add the path to the folder containing that file into LD_LIBRARY_PATH.

Share:
14,173
Srivishnu Piratla
Author by

Srivishnu Piratla

Updated on June 08, 2022

Comments

  • Srivishnu Piratla
    Srivishnu Piratla almost 2 years

    I am trying to install tensorflow with cuda and gpu support. When I try to import it, I get the following error:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/srivishnu/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
        from tensorflow.python import *
      File "/home/srivishnu/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "/home/srivishnu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "/home/srivishnu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "/home/srivishnu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "/home/srivishnu/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
    ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
    

    this error occurs when I type this command in:

    import tensorflow as tf
    

    Can you please help me solve this problem

  • Braelyn B
    Braelyn B almost 6 years
    How do you update the LD_LIBRARY_PATH to point to the proper lib?
  • David Parks
    David Parks almost 6 years
  • anthony
    anthony over 5 years
    Better still (and faster) is use: locate libcublas