The CUDA (Compute Unified Device Architecture) toolkit from Nividia provides everything to develop GPU accelerated applications. It is a parallel computing platform that includes accelerated libraries, a compiler, development tools, and CUDA runtime.
Nvidia CUDA is designed to work with programming languages such as C, C++, Fortran, etc.
In this article, I will discuss how to install the Nvidia CUDA toolkit on Ubuntu.
Prerequisites
To follow this guide you should have the following –
- Access to a user account that has superuser privileges
- You should have the Nvidia graphics driver installed on your system
How to install CUDA on Ubuntu
There are multiple ways using which you can install CUDA on a Ubuntu system. Use one of the given methods to install it on your system.
Method 1: Installing CUDA from Ubuntu repository
The CUDA is available in the official repository of Ubuntu. Installing a package from the Ubuntu software repository is one of the easiest methods to install software on a Ubuntu system.
Before your run the command to install CUDA make sure your apt repository is updated –
sudo apt update
Next, run the given command to install the CUDA toolkit –
sudo apt install nvidia-cuda-toolkit
Press y and then Enter when it asks for your confirmation.
You can verify the installation by using the given command –
nvcc --version
Method 2: Installing CUDA toolkit from its official repository
In this method first, you have to enable the Nvidia CUDA repository on your Ubuntu system. Using this method you will get the latest released version of this software from Nvidia.
First, use the given command to download the CUDA pin in /etc/preferences.d
directory-
sudo wget -O /etc/apt/preferences.d/cuda-repository-pin-600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
Run the given command to download the CUDA toolkit on your system –
wget https://developer.download.nvidia.com/compute/cuda/11.6.1/local_installers/cuda-repo-ubuntu2004-11-6-local_11.6.1-510.47.03-1_amd64.deb
Use the following command to execute CUDA on your Ubuntu system-
sudo dpkg -i cuda-repo-ubuntu2004-11-6-local_11.6.1-510.47.03-1_amd64.deb
Next, run the given commands to download the CUDA GPG key –
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
Refresh the apt repository by using –
sudo apt update
Finally, use the given command to install the CUDA toolkit on your system –
sudo apt install cuda
Press y and then Enter when it asks for your confirmation.
Conclusion
Here we explained different methods to install the CUDA toolkit on a Ubuntu system. Now if you have a query then write us in the comments below.
When installing cuda from Ubuntu repository your nvidia-cuda-ultis package with nvidia-smi gets removed!