sudo apt purge nvidia*
sudo apt remove nvidia-*
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt autoremove && sudo apt autoclean
sudo rm -rf /usr/local/cuda*
Restart the machine
sudo shutdonw -r now
# to verify your gpu is cuda enable check
lspci | grep -i nvidia
# gcc compiler is required for development using the cuda toolkit. to verify the version of gcc install enter
gcc --version
Add the ppa:graphics-drivers/ppa repository into your system
sudo add-apt-repository ppa:graphics-drivers/ppa
Install drivers (tip: type sudo apt install nvidia-driver- and press tab to see all posiible driver versions)
sudo apt install nvidia-driver-550
sudo shutdown -r now
After the reboot check driver version
nvidia-smi
You should see something like this
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.100 Driver Version: 550.100 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| 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:03:00.0 Off | N/A |
| 0% 24C P8 6W / 370W | 2MiB / 24576MiB | 0% Default |
| | | N/A |
If you need CUDA Tolkit 12 with nvcc
, other tools and libraries you can install it from NVIDIA Ubunutu 22.04 repository.
Add Ubuntu 22.04 repository
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
Add public keys
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /"
Update and install cuda toolkit, you will gain access to many version of cuda and cuda toolkit.
Write apt install cuda-toolkit
and press tab it will show list of all available versions
sudo apt update
sudo apt install cuda-toolkit-12-1
having a NVidia repositories added you can type
sudo apt install cudnn9-cuda-12
Edit /home/$USER/.bashrc
file
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
export PATH="/usr/local/cuda/bin:$PATH"
New drivers automatically install some xorg server packages and it activates power management options. Probably on your server you want to disable power management (sleep, hibernate).
sudo systemctl mask sleep.target suspend.target hibernate.target