27

So 20.04 got released two days ago, but when is CUDA for 20.04 gonna be released? Is Nvidia usually following up quickly?

  • 1
    The 18.04 CUDA releases run fine on 20.04. The only trick is ensuring you don't replace the current Nvidia drivers from the standard repositories with some ancient version which all the cuda packages depend upon. A local extract of the cuda files works fine. – ubfan1 Apr 25 at 4:59
26

For Cuda only, you can refer to @meetnick's answer.

As per June, 16th, 2020, I managed to install CUDA 10.1 and cuDNN 7.6.5 on Ubuntu 20.04 and they work perfectly with Tensorflow 2.2.0
Here are the steps that I followed

1- Install CUDA (10.1):

As per now, there is no deb file or run file for Ubuntu 20.04, so the only solution is to run:

sudo apt install nvidia-cuda-toolkit

It will take a while to be installed.
After that, to make sure that CUDA is installed, run:

nvcc -V  

You would get an output similar to the following:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243  

This means that CUDA is successfully installed on your Ubuntu 20.04.
The slight difference is that cuda is not installed in the usual path (/usr/local/cuda, /usr/local/cuda-10.1). Instead, it is installed in /usr/lib/ (/usr/lib/cuda/).
You can get where CUDA is installed by running the following command:

whereis cuda 

2- Install cuDNN (7.6.5):

first go to this link then choose Download cuDNN. You'll be asked to login/create an account. After logging in, you'll be asked to accept the Terms of the cuDNN Software License Agreement.
A list of downloadable cuDNN will be displayed, click on Download cuDNN v7.6.5 (November 5th, 2019), for CUDA 10.1 then choose cuDNN Library for Linux.
After the download is finished, extract the file, then open the terminal and run:

cd cudnn-10.1-linux-x64-v7.6.5.32 # or whatever folder you got after extracting the file

Then:

sudo cp cuda/include/cudnn.h /usr/lib/cuda/include/

After that:

sudo cp cuda/lib64/libcudnn* /usr/lib/cuda/lib64/

Finally:

sudo chmod a+r /usr/lib/cuda/include/cudnn.h /usr/lib/cuda/lib64/libcudnn*

Once you finish, you have to add the CUDA path to your ~/.bashrc file. You need to run:

echo 'export LD_LIBRARY_PATH=/usr/lib/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/lib/cuda/include:$LD_LIBRARY_PATH' >> ~/.bashrc  

Then run:

source ~/.bashrc 

3- Optional:
Now you can install Tensorflow-gpu (2.2.0) and test if uses your GPU or not.
pip3 install tensorflow-gpu==2.2.0
Then run python3 and type the following lines:

import tensorflow as tf
tf.config.list_physical_devices('GPU')

If everything went as planned, you'll get an output telling that Tensorflow has access to your GPU.

| improve this answer | |
  • This answer really helped me a lot. I have one question, Why the same steps doesn't work with 10.2 only 10.1? – Moustafa Mahmoud Jul 16 at 1:33
  • 1
    @MoustafaMahmoud, I didn't try Cuda 10.2, I only tried Cuda 10.1. I really have no idea. I hope the community can help. – singrium Jul 16 at 8:04
  • 1
    Thank you so much. This helped me a lot! :) – afagarap Jul 20 at 16:33
10

There's already built-in CUDA packages in Ubuntu 20.04, you can install it by typing:

sudo apt-get install nvidia-cuda-toolkit

Due this date, it install CUDA 10.1.

Besides @ubfan1 answer is correct, if you're CUDA application developer, you may face problems by installing the 18.04 CUDA, this is because CUDA on 18.04 repositories is incompatible with 20.04 GCC (which is 9.3 due this date). In this case, I pretty much suggest installing the build-in CUDA package.

| improve this answer | |
  • 2
    I am using the cuda_10.1_ubuntu_18.04 installation (with Cudnn and tensorRT) as described in the tensorflow website (I had to manually install cudnn and tensorRT since apt couldn't find them) and it runs fine in my 20.04. nvidia-cuda-toolkit didn't help at all. – paulplusx Apr 26 at 12:24
  • 2
    Indeed nvidia-cuda-toolkit doesn't install neither cudnn nor tensorRT. These libraries requires mandatory download from nvidia download center. – meetnick Apr 26 at 14:08
  • 1
    Thank you so much. This helped me a lot! :) – afagarap Jul 20 at 16:33
8

NVIDIA Cuda 11 Toolkit for Ubuntu 20.04 is finally released.

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 apt install ./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
| improve this answer | |
  • Really good news! Earlier than advertised ! – abu_bua Jul 10 at 16:57
4

Ubuntu 20.04 LTS and CUDA 11.1 setup:

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/ /"
sudo apt update
sudo apt install -y nvidia-kernel-source-455
sudo apt install -y nvidia-dkms-455
sudo apt install -y nvidia-driver-455
sudo apt install -y cuda-drivers-455
sudo apt install -y cuda-runtime-11-1
sudo apt install -y cuda-11-1
echo 'export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}' >> $HOME/.bashrc
| improve this answer | |
3

Your question is when, well that just Nvidia knows, but you can look at the past to get an idea. There was no releases for Ubuntu 19.04 nor Ubuntu 19.10. And earlier for Ubuntu 18.10, was released the 2018-10-18, and there was no CUDA release until the 2019-02-26. And OFC it reached end of life and got no further updates after the 10.1.

Right now if you want the last version (10.2) you have to go to the last LTS that was Ubuntu 18.04 not sure if that repository works on Ubuntu 20.04, did not dare update yet. But they said in the comments that it works. And Ubuntu 18.04 was released the 2018-04-26, and there was no CUDA release until the 2018-09-18.

As you can see it takes them quite a few month to do it.

It gives me the idea that Nvidia does not care about Linux.

| improve this answer | |
  • 2
    They don't care about Linux, but they care about DL, and CUDA for Linux is needed there... – Kai Yang May 6 at 17:44
1

To expand on singrium's post, if those directions still don't work for you go ahead and try this link where I think they got their directions from: https://illya13.github.io/RL/tutorial/2020/04/26/installing-tensorflow-on-ubuntu-20.html

The big points are that gpu support on 20.04 currently only works with Python 3.5 - 3.7 and gcc 8 which Ubuntu does NOT come preinstalled with. Go figure. Even after doing all that, I was still getting a libcudnn.so.7 error. I found out it was because I was running my script in Pycharm. Once I made my own virtual env and ran from command line my gpu was picked up by tensorflow and I was good to go. I think this must have something to do with Pycharm not picking up the LD_LIBRARY_PATH and forwarding that along to tf but who knows. Hope this helps someone!

| improve this answer | |
0

Managed to install CUDA 11.0.207, cuDNN 8.0.1 on 20.04 following these instructions.

Cuda download link up to installer type:

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=2004

Just as a side note, run this to find the recommended driver for your machine

ubuntu-drivers devices

and make sure that it matches the version of cuda toolkit you want to install (see Table 2 here)

Check your local driver version with:

nvidia-smi

Check your local cuda version (if any):

nvcc --version

or

cat /usr/local/cuda/version.txt
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.