Menu

How to install CUDA on Ubuntu

## 1. Installation of the driver for GPU (if it is not installed yet) Download the driver from NVIDIA official website: [https://www.nvidia.ru/Download/index.aspx?lang=ru](https://www.nvidia.ru/Download/index.aspx?lang=ru) In my case the downloaded file is named: `NVIDIA-Linux-x86_64-440.44.run` In order to install it, we switch to the console more with `Ctrl + Alt + F3` and run the commands from the list: 1. Turning off lightdm service: `sudo service lightdm stop` 2. Run the downloaded file: `sudo bash NVIDIA-Linux-x86_64-570.133.07.run` 3. Restart the computer: `sudo reboot` If everything is installed correctly, the command `nvidia-smi` should show the information about your GPU and the driver's version: ``` Fri Apr 11 12:03:10 2025 +-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 570.133.07 Driver Version: 570.133.07 CUDA Version: 12.8 | |-----------------------------------------+------------------------+----------------------+ | 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 NVIDIA GeForce RTX 3090 Off | 00000000:04:00.0 On | N/A | | 37% 53C P5 43W / 350W | 3094MiB / 24576MiB | 66% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+ +-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | 0 N/A N/A 2923 G /usr/lib/xorg/Xorg 1846MiB | | 0 N/A N/A 3149 G /usr/bin/gnome-shell 142MiB | | 0 N/A N/A 5575 G ...ersion=20250409-205551.032000 546MiB | | 0 N/A N/A 191600 G ...setup.5.5.5/Telegram/Telegram 4MiB | | 0 N/A N/A 203678 G /usr/bin/nautilus 42MiB | | 0 N/A N/A 204705 G /opt/zoom/zoom 258MiB | +-----------------------------------------------------------------------------------------+ ``` ## 2. CUDA installation Download from NVIDIA official website: [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads) Choose `deb (local)` and run the commands listed there. In my case they are following: ``` wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin sudo mv cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600 wget https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda-repo-ubuntu2404-12-8-local_12.8.1-570.124.06-1_amd64.deb sudo dpkg -i cuda-repo-ubuntu2404-12-8-local_12.8.1-570.124.06-1_amd64.deb sudo cp /var/cuda-repo-ubuntu2404-12-8-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo apt-get update sudo apt-get -y install cuda-toolkit-12-8 ``` After that restart the computer and try `nvidia-smi` again. ## 3. Appending PATH Insert `export PATH=/usr/local/cuda/bin:$PATH` into `~/.bashrc`. After that open terminal and run `nvcc --version` that will output the version of CUDA compiler: ``` nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2024 NVIDIA Corporation Built on Tue_Oct_29_23:50:19_PDT_2024 Cuda compilation tools, release 12.6, V12.6.85 Build cuda_12.6.r12.6/compiler.35059454_0 ```

© Alexander Khlebushchev 2015 - now