How to install libcudart11.0

I installed tensorflow-gpu v2.9.0 using pip on Ubuntu 20.04. But I get this error when importing tensorflow: “Could not load dynamic library ‘libcudart.so.11.0’; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory”

How can I install libcudart v11.0? I was not able to install it using sudo apt-get install libcudart11.0 although I have installed previous versions (libcudart10.2) of it using apt-get. I also tried “sudo apt-get install cuda-cudart-11-0” but the package could not be located.

@tensorflow_user,

Welcome to the Tensorflow Forum,

You can install CUDA 11.0 as shown below

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda-repo-ubuntu2004-11-0-local_11.0.2-450.51.05-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-0-local_11.0.2-450.51.05-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-0-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

Thank you!

@chunduriv Thanks for your reply.

The installation (sudo apt-get -y install cuda) failed.

Errors were encountered while processing:
nvidia-dkms-450
nvidia-driver-450
cuda-drivers-450
cuda-drivers
cuda-runtime-11-0
cuda-11-0
cuda-demo-suite-11-0
cuda
E: Sub-process /usr/bin/dpkg returned an error code (1)

import tensorflow as tf
tf.config.list_physical_devices(‘GPU’)
2023-07-04 15:07:23.376576: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2023-07-04 15:07:23.376653: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:200] libcuda reported version is: 450.51.5
2023-07-04 15:07:23.376671: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:204] kernel reported version is: 525.116.4
2023-07-04 15:07:23.376676: E tensorflow/stream_executor/cuda/cuda_diagnostics.cc:313] kernel version 525.116.4 does not match DSO version 450.51.5 – cannot find working devices in this configuration

@tensorflow_user,

Can you try following command and let us know?

sudo apt-get install libcudart.so.11.0

Thank you!

sudo apt-get install libcudart.so.11.0
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package libcudart.so.11.0
E: Couldn’t find any package by glob ‘libcudart.so.11.0’
E: Couldn’t find any package by regex ‘libcudart.so.11.0’

Hi,

Verify the CUDA repository: If you’re using NVIDIA’s CUDA, make sure the CUDA repository is listed among your package sources. The official NVIDIA documentation includes steps for adding the CUDA repository.

Also, ensure to update your package lists

sudo apt-get update

I hope that helps

@Ibrahimgoke Could you share more specific instructions on how to do this for the benefit of everyone? Thanks

@tensorflow_user,

Previously there were similar scenarios which is more similar to your usecase and that proved successful.

You will need to remove all Nvidia repository references and purge all the packages they installed. The easiest way to do this is usually to do a full re-installation of Ubuntu.

After you have fully removed the Nvidia packages, re-install the nvidia driver along with nvidia-cuda-toolkit and nvidia-cudnn apt packages from the official Ubuntu repositories.

Thank you!

In case anybody else is having the same issue, I installed CUDA11.2 using conda in a conda environment (avoid installing CUDA system wide for tensorflow).

conda install -c conda-forge cudatoolkit=11.2.2 cudnn=8.1.0

After this, I still encountered the ‘libcudart.so.11.0’ missing error from tensorflow. Assuming CUDA was installed properly, the location of libcudart must be added to LD_LIBRARY_PATH. See below.

# first identify the location of libcudart.so.11.0 in your system
sudo find / -name 'libcudart.so.11.0' # this will return the location
# then add the location to LD_LIBRARY_PATH (below was the location on my system, replace with your own)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/miniconda3/envs/cuda-env/lib

@chunduriv thanks for your help!