ImportError: libcublas.so.9.0: cannot open shared object file

I am using Ubuntu 18.04.1 LTS I installed cuda-9.0, Pytorch 0.4, libcupti and cuDNN 7.0 for deep learning purposes.
I got error:
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

GPU: GeForce GTX 1050/PCIe/SSE2
| NVIDIA-SMI 415.23       Driver Version: 415.23       CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   49C    P5    N/A /  N/A |    474MiB /  4042MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1104      G   /usr/lib/xorg/Xorg                            28MiB |
|    0      1198      G   /usr/bin/gnome-shell                          48MiB |
|    0      1384      G   /usr/lib/xorg/Xorg                           254MiB |
|    0      1571      G   /usr/bin/gnome-shell                         137MiB |
|    0      2148      G   /usr/lib/firefox/firefox                       1MiB |
|    0      3136      G   /usr/lib/firefox/firefox                       1MiB |
|    0      7041      G   gnome-control-center                           1MiB |
+-----------------------------------------------------------------------------+

test gpu install

python -c 'import torch; print(torch.rand(2,3).cuda())'

    tensor([[0.9905, 0.9057, 0.2803],
            [0.3525, 0.1388, 0.0692]], device='cuda:0')

I checked Python environment is already configured:

Python 3.6.6 :: Anaconda, Inc.
pip 18.1 from /home/wojtek/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
virtualenv --version
16.1.0

I installed tensorflow-gpu using conda.
test gpu install:

python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
2018-12-17 16:13:24.226023: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-12-17 16:13:24.307372: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-12-17 16:13:24.307737: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties: 
name: GeForce GTX 1050 major: 6 minor: 1 memoryClockRate(GHz): 1.493
pciBusID: 0000:01:00.0
totalMemory: 3.95GiB freeMemory: 3.61GiB
2018-12-17 16:13:24.307750: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2018-12-17 16:13:24.488105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-12-17 16:13:24.488132: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0 
2018-12-17 16:13:24.488137: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N 
2018-12-17 16:13:24.488337: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3329 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1)
tf.Tensor(471.4757, shape=(), dtype=float32)
echo $LD_LIBRARY_PATH
/usr/local/cuda/lib64:
(base) wojtek@wojtek-GF63-8RC:~$  ls /usr/local/cuda-9.0/lib64
libaccinj64.so          libcusparse.so          libnppist.so.9.0
libaccinj64.so.9.0      libcusparse.so.9.0      libnppist.so.9.0.176
libaccinj64.so.9.0.176  libcusparse.so.9.0.176  libnppist_static.a
libcublas_device.a      libcusparse_static.a    libnppisu.so
libcublas.so            libnppc.so              libnppisu.so.9.0
libcublas.so.9.0        libnppc.so.9.0          libnppisu.so.9.0.176
libcublas.so.9.0.176    libnppc.so.9.0.176      libnppisu_static.a
libcublas_static.a      libnppc_static.a        libnppitc.so
libcudadevrt.a          libnppial.so            libnppitc.so.9.0
libcudart.so            libnppial.so.9.0        libnppitc.so.9.0.176
libcudart.so.9.0        libnppial.so.9.0.176    libnppitc_static.a
libcudart.so.9.0.176    libnppial_static.a      libnpps.so
libcudart_static.a      libnppicc.so            libnpps.so.9.0
libcudnn.so             libnppicc.so.9.0        libnpps.so.9.0.176
libcudnn.so.7           libnppicc.so.9.0.176    libnpps_static.a
libcudnn.so.7.0.5       libnppicc_static.a      libnvblas.so
libcudnn_static.a       libnppicom.so           libnvblas.so.9.0
libcufft.so             libnppicom.so.9.0       libnvblas.so.9.0.176
libcufft.so.9.0         libnppicom.so.9.0.176   libnvgraph.so
libcufft.so.9.0.176     libnppicom_static.a     libnvgraph.so.9.0
libcufft_static.a       libnppidei.so           libnvgraph.so.9.0.176
libcufftw.so            libnppidei.so.9.0       libnvgraph_static.a
libcufftw.so.9.0        libnppidei.so.9.0.176   libnvrtc-builtins.so
libcufftw.so.9.0.176    libnppidei_static.a     libnvrtc-builtins.so.9.0
libcufftw_static.a      libnppif.so             libnvrtc-builtins.so.9.0.176
libcuinj64.so           libnppif.so.9.0         libnvrtc.so
libcuinj64.so.9.0       libnppif.so.9.0.176     libnvrtc.so.9.0
libcuinj64.so.9.0.176   libnppif_static.a       libnvrtc.so.9.0.176
libculibos.a            libnppig.so             libnvToolsExt.so
libcurand.so            libnppig.so.9.0         libnvToolsExt.so.1
libcurand.so.9.0        libnppig.so.9.0.176     libnvToolsExt.so.1.0.0
libcurand.so.9.0.176    libnppig_static.a       libOpenCL.so
libcurand_static.a      libnppim.so             libOpenCL.so.1
libcusolver.so          libnppim.so.9.0         libOpenCL.so.1.0
libcusolver.so.9.0      libnppim.so.9.0.176     libOpenCL.so.1.0.0
libcusolver.so.9.0.176  libnppim_static.a       stubs
libcusolver_static.a    libnppist.so

Thanks in advance.

It looks like you installed CUDA 9.0 using a CUDA toolkit installer. Nothing wrong with that, but then you have to work through the path/environment variables issues to help your conda environment or python virtualenv environment find it. You’ll find plenty of descriptions of this on the web.

I find it is often easier when using a package installed using conda (eg. tensorflow-gpu) that has a dependency on cuda, to just install the cuda toolkit from within your conda environment.

Done. Thank you.