How to install NVIDIA CUDA on Ubuntu 20.04?

Overview

CUDA (Compute Unified Device Architecture) is a parallel computing platform and programming style created by NVIDIA to speed up computational operations.

CUDA has a number of benefits, some of which are stated below:

  1. CUDA-capable GPUs have hundreds of cores that can execute thousands of computational threads simultaneously. A number of technologies, including deep learning, are dominated by the combination of NVIDIA GPUs and CUDA, which also serves as the basis for the world's fastest computers.

  2. Offer a condensed set of extensions to common programming languages, like C, that make it simple to build and implement parallel algorithms. C/C++ programmers can concentrate on parallelizing algorithms with CUDA rather than spending time on their implementation.

Learn step-by-step instructions on how to install NVIDIA CUDA on Ubuntu 20.04 for GPU acceleration and improved performance on deep learning tasks.

Prerequisites

There are certain prerequisites that need to be met before you begin.

  • Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa

  • A sudo-privileged user account

  • CUDA-capable GPU

Key

  • Red Color: Input

  • Green Color: Output

Get Started

Step 1: Move to the directory on your server to download CUDA 12 toolkit.

cd <download_directory>

Step 2: Download cuda-ubuntu.pin file.

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin

Step 3: Move the cuda-ubuntu2004.pin file.

sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600

Step 4: Download NVIDIA CUDA for Ubuntu version 20.04 using the following code:

wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda-repo-ubuntu2004-12-0-local_12.0.0-525.60.13-1_amd64.deb

Step 5: Install CUDA 12 kit for Ubuntu version 20.04 using the following code:

sudo dpkg -i cuda-repo-ubuntu2004-12-0-local_12.0.0-525.60.13-1_amd64.deb

Step 6: Install the necessary keys for the software package's authentication using the following code:

The apt-key tool maintains the list of number of keys that apt uses to verify packages. Reliable packages are those that have undergone these keys' authentication.

sudo cp /var/cuda-repo-ubuntu2004-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/

Step 7: Use the following command to update software packages of CUDA.

sudo apt-get update

Step 8: Install CUDA using the below command:

sudo apt-get install

Last updated