I tried to install and run Tensorflow on a Ubuntu 20.04 laptop with a Nvidia GPU but I encountered the "could not load dynamic library 'libcudart.so.11.0'" error message, as shown in the screenshot below.
To resolve the issue, I had to install the Nvidia kernel and Cuda 11 libraries from the Nvidia repository. The steps are outlined below.
- On the Ubuntu machine, open a Terminal. Type in the following commands to add the Nvidia ppa repository:
$ 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 && sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
$ sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" - In the Terminal, type in the commands to install the Nvidia kernel.
$ sudo apt-get update && sudo apt-get install -y nvidia-kernel-source-460 - Finally, install Cuda with the following command.
$ sudo apt-get -y install cuda
Subsequently when importing the Tensorflow library, the error message no longer appears.
Note: Download and install any additional missing libraries from https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ if necessary.