Install CUDA for Ubuntu in 5 mins
One tweet from https://twitter.com/finbarrtimbers says:
I enjoyed the CUDA driver installation for 2 days plus another day to reinstall the whole system around 2 years ago.
Now in 2023, with the correct steps, you can only enjoy CUDA drivers installation for just 5 mins in Ubuntu, here are the steps:
Step 1. If you have Nvidia’s driver already installed, you’d better uninstall all Nvidia drivers first to ensure minimum errors.
sudo apt-get purge 'nvidia*'
sudo apt-get autoremove
You don’t have to reboot system after purging, in case you don’t have the CPU integrated GPU like many Intel CPUs have, you may have display troubles after rebooting before having new GPU drivers installed.
Step 2. Install GCC if you don’t have one
sudo apt install gcc
Step 3. Install NVIDIA GPU driver
sudo apt update
sudo apt upgrade
sudo apt install build-essential dkms
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
# list all avaliable drivers
sudo apt install ubuntu-drivers-common
sudo ubuntu-drivers devices
# auto install
sudo ubuntu-drivers autoinstall
# or with a version
# sudo apt install nvidia-driver-525