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.
3 comments:
Thank you, but I have done somethign horrible, I'm sure ._.
sudo apt-get -y install cuda
The following packages have unmet dependencies:
cuda : Depends: cuda-11-5 (>= 11.5.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
sudo apt-get -y install cuda
The following packages have unmet dependencies:
cuda : Depends: cuda-11-5 (>= 11.5.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
With Ubuntu 21.04:
pip3 install tensorflow
sudo apt install nvidia-cuda-toolkit
should resolve it.
Post a Comment