How to install CUDA on Ubuntu
Download CUDA Toolkit :
$ 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 https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda-repo-ubuntu2004-11-0-local_11.0.3-450.51.06-1_amd64.deb
$ sudo dpkg -i cuda-repo-ubuntu2004-11-0-local_11.0.3-450.51.06-1_amd64.deb
$ sudo apt-key add /var/cuda-repo-ubuntu2004-11-0-local/7fa2af80.pub
$ sudo apt-get update
Purge previous Nvidia packages:
sudo apt clean
sudo apt update
sudo apt-get purge nvidia-*
sudo apt autoremove
Install CUDA Toolkit:
$ sudo apt-get -y install cuda
Add Cuda to the PATH
:
$ vi ~ /.bash_profile
export CUDADIR=/usr/local/cuda
export PATH=$PATH :$CUDADIR /bin
export LD_LIBRARY_PATH=$CUDADIR /lib64:$LD_LIBRARY_PATH
$ source ~ /.bash_profile
Check the CUDA version:
$ nvidia-smi
Fri Jun 25 17:36:29 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 |
| -------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
| ===============================+======================+======================|
| 0 A100-PCIE-40GB On | 00000000:C5:00.0 Off | 0 |
| N/A 37C P0 34W / 250W | 4MiB / 40537MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
| 1 A100-PCIE-40GB On | 00000000:C8:00.0 Off | 0 |
| N/A 35C P0 33W / 250W | 4MiB / 40537MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
...
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Wed_Jul_22_19:09:09_PDT_2020
Cuda compilation tools, release 11.0, V11.0.221
Build cuda_11.0_bu.TC445_37.28845127_0