Install CUDA for Ubuntu in 5 mins

Andrew Zhu (Shudong Zhu)
2 min readMay 14, 2023

One tweet from https://twitter.com/finbarrtimbers says:

Source: https://twitter.com/finbarrtimbers/status/1657154970213572608

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

Then reboot your system:

sudo reboot

You may want to disable the UEFI secure boot from the BIOS, if not doing it, you will be asked to input a password and then enroll the key, it will work, but require additional steps and may lead to driver installation failure.

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
#…

--

--