Introduction
CUDA toolkit is an extension of the Graphics Processing Unit parallel computing architecture developed by NVIDIA. It also enhances the performance of the computer by using the power of the GPU. Programmers can use it through popular programming languages. We can install the CUDA toolkit from the Ubuntu repository.
Below is the guide on how to install CUDA on Ubuntu 20.04.
Installing the CUDA toolkit from the Ubuntu repository
Step 1 – Update packages from the Internet by apt command:
$ sudo apt update
Output:
Step 2 – Now we start installing the CUDA toolkit by apt command:
$ sudo apt install nvidia-cuda-toolkit
Output:
Add CUDA to PATH
After installing, we must add CUDA to PATH, so that the shell knows where CUDA is located. Let’s open the .profile file by vim command:
$ sudo vim ~/.profile
Then add the following lines to the end of the file and save:
# set PATH for cuda 10.1 installation if [ -d "/usr/local/cuda-10.1/bin/" ]; then 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
After finishing, let’s reboot your computer:
$ sudo reboot
Check your CUDA version
$ nvcc --version
Output:
Conclusion
You’ve already gone through the details of how to install CUDA on Ubuntu 20.04.
Thanks for reading.