ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

Hi there,

I have installed Cuda and cudnn on Ubuntu 18.04 and it seems to be installed OK:

user:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105
user:~$ nvidia-smi 
Mon Mar 18 14:36:47 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.43       Driver Version: 418.43       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro K5200        Off  | 00000000:03:00.0  On |                  Off |
| 26%   39C    P8    14W / 150W |    225MiB /  8118MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1538      G   /usr/lib/xorg/Xorg                            32MiB |
|    0      1583      G   /usr/bin/gnome-shell                           5MiB |
|    0      3008      G   /usr/lib/xorg/Xorg                           100MiB |
|    0      3120      G   /usr/bin/gnome-shell                          82MiB |
+-----------------------------------------------------------------------------+

However, when I try to import tensorflow GPU I get import error for libcublas.so.10.0:

$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory

What do I need to install to fix this problem? Is there something missing?
Thanks
Amin

For me the same error occurred, but the output of the nvidia-smi command was as follows:

Failed to initialize NVML: Driver / library version mismatch

Obviously, it was linked against cuda 10.0. Try creating a symlink in /usr/lib/x86_64-linux-gnu/
ln -s libcublas.so.10 libcublas.so.10.0
If that doesn’t work, either downgrade to cuda 10.0 or build tensorflow from source.

Thanks for your suggestion.
I did try to create a symlink:
user:/$ sudo ln -s libcublas.so.10 libcublas.so.10.0
[sudo] password for user:

but the problem was still there when I import tensorflow.

How can I downgrade cuda? do I need to uninstall this version? or can I have both 10.0 and 10.1?
if so, can I remove it using the following?:

sudo apt-get remove cuda-toolkit-10-1

or

sudo apt-get purge cuda-toolkit-10-1

?

I guess for installation of 10.0 I need to do this:

sudo apt install cuda-toolkit-10-0

correct?

Thanks
Amin

sudo apt-get remove cuda-toolkit-10-1
should be sufficient. Afterwards,
sudo apt install cuda-toolkit-10-0
is correct.

Thanks for your help.
I managed to uninstall 10.1, but there is no 10.0 or 10?

user:~$ sudo apt install cuda-toolkit-10-0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package cuda-toolkit-10-0
user:~$ sudo apt install cuda-toolkit-10
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package cuda-toolkit-10

what should I do? thanks
Amin

Requires manual download:
https://developer.nvidia.com/cuda-10.0-download-archive

I’m running Unbuntu Server 18.10

Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:        18.10
Codename:       cosmic

The only version that would install for me is: Deb(network)

the others would error out.

Thanks to both of you. I managed to installed CUDA and cudnn 10.0 and via Deb (Network) and now I can import tensorflow successfully.