Install NVIDIA driver on your ubuntu

Linux
Ubuntu

Install the official NVIDIA driver using a third-party library and disable the open-source driver.

Author

Guofeng Lin

Published

November 30, 2023

1. add third-party repositpry PPA

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

2. disable the open-source driver nouveau

Ubuntu uses the open-source driver nouveau by default, so you need to disable nouveau before installing the NVIDIA driver.

sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

Then you can enter the following command to verify that the above command was entered into the file “/etc/modprobe.d/blacklist-nvidia-nouveau.conf”.

cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf

It works if the following message is displayed:

$ cat /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0

3. Install the official NVIDIA driver

Uninstall the old NVIDIA driver (if needed):

sudo apt-get purge nvidia*

Add drivers to PPA repository:

sudo add-apt-repository ppa:graphics-drivers
sudo apt-get update

Search for latest NVIDIA drivers:

sudo apt-cache search nvidia

Search for recommanded NVIDIA drivers:

ubuntu-drivers devices

Open “Ubuntu Software” in your system, then click “Software & Updates” in the upper left corner, then click “Additional Drivers,” select one of the drivers (I find it best to choose a newer, proprietary driver), and then click “Apply Changes.” After installation, the system will ask you to restart. If the screen looks great after restarting, you’re all done!

View the current driver:

nvidia-smi