This tutorial is about How to install CUDA on Ubuntu 20.04 LTS Linux. Recently I updated this tutorial and will try my best so that you understand this guide. I hope you guys like this blog, How to install CUDA on Ubuntu 20.04 LTS Linux. If your answer is yes after reading the article, please share this article with your friends and family to support us.
Table of contents
Check How to install CUDA on Ubuntu 20.04 LTS Linux
The Nvidia CUDA toolkit is an extension of the GPU parallel computing platform and programming model. Installing Nvidia CUDA consists of ingesting the official Nvidia CUDA repository, followed by installing the corresponding metapackage and setting the path of the CUDA executable binaries. The full form of CUDA is Compute Unified Device Architecture. CUDA is a parallel computing platform and programming model developed by NVIDIA. It is used to run programs on NVIDIA graphics processing units (GPUs) to dramatically speed up computing applications.
In this guide, we will show you how to install CUDA on Ubuntu 20.04 LTS from the official Ubuntu package repository. We also show you how to install the latest version of CUDA on Ubuntu 20.04 LTS from the official NVIDIA package repository. We’ll also show you how to write, compile, and run your first CUDA program.
How to install CUDA on Ubuntu 20.04 LTS Linux
Install CUDA from the Ubuntu repository
- Start by updating the package lists on your Ubuntu 20.04 instance.
- Next, install the CUDA toolkit using the APT package manager as follows. Please note that the installation is intensive and as such make sure you have a fast and stable internet connection and a minimum of 10G of disk space.
-
- $ sudo apt install nvidia-cuda-toolkit
- Once the installation is complete, we need to add CUDA to PATH to notify the shell of the location of CUDA. To do this, we will specify the PATH in the .bashrc file. So, open the file using your command line text editor.
- At the end of the file, copy and paste the following lines of code.
-
- # set the PATH for cuda 10.1 installation
- Yes [ -d “/usr/local/cuda-10.1/bin/” ]; so
- export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- fi
- Then upload the changes back to the .bashrc file.
- Now check and confirm the CUDA version installed using the following command.
Install CUDA from the CUDA repository
As mentioned above, the CUDA repository provides the latest version of CUDA. Therefore, if you want to install the latest version, follow the instructions described in this document.
- First, download the pin from the CUDA repository:
- $ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
- Next, move the pin to the /etc/preferences.d directory and rename it cuda-repository-pin-600.
- $ sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
- Thereafter, download the CUDA Debian archive. Note that the file is quite large – 2.3G to be precise at the time of writing this guide. Make sure you have a good internet connection and enough disk space.
- $ wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb
- Once downloaded, use the dpkg utility to run the file.
- sudo dpkg -i cuda-repo-ubuntu2004-11-4-local_11.4.2-470.57.02-1_amd64.deb
- Next, install the CUDA GPG key as follows:
- $ sudo apt-key add /var/cuda-repo-ubuntu2004-11-4-local/7fa2af80.pub
- Finally, update the package lists and install CUDA using the APT package manager.
- $ sudo apt update
- $ sudo apt install cuda -y
Final remarks: How to install CUDA on Ubuntu 20.04 LTS Linux
I hope you understand this article, How to install CUDA on Ubuntu 20.04 LTS Linux. If your answer is no, you can ask anything via the contact forum section related to this article. And if your answer is yes, please share this article with your friends and family to give us your support.