In this article, I will share my experience to install NVIDIA driver on Linux OS (Ubuntu 18.04). I have been through some problem when try install or upgrade the NVIDIA driver. Before we start, there’s some notes.
- Never mixed up install from apt and installer file. If you willing to install from installer file to get latest driver version, always remove all previous NVIDIA installation.
- Always reboot/restart your Linux OS after installation
- In order to use the NVIDIA GPU, please follow instruction to disable secure boot (when install the driver, they will provide instruction how to do it, please read carefully their instruction).
There will be 2 ways to install the NVIDIA driver, first using apt-get, second way is using installer (runfile).
Install NVIDIA Driver via apt-get
Basically, this driver provided in ubuntu official repository. We can check it using this command
$ sudo ubuntu-drivers devices
and we will get the list of NVIDIA driver. To install the driver, we just need to run this simple command
$ sudo apt-get install nvidia-driver-418 nvidia-modprobe
in those command example, I pick version 418, you can choose what version is suitable for you. We also install nvidia-modprobe, it’s a utility to load NVIDIA kernel modules and crate NVIDIA character device files automatically every time your machine booting up.
Install NVIDIA Driver via Installer (Runfile)
This part is recommended for advanced user. When install via apt-get is quite simple, otherwise, install with installer(runfile) need more steps and need be more carefully.
Remove Previous Installations
In case you installed NVIDIA driver before, it’s very recommended, must remove previous installation.
$ sudo apt-get purge nvidia*
Download the NVIDIA Driver
Latest NVIDIA drivers can be download from their official website ( https://www.nvidia.com/object/unix.html )
Install the Dependencies
Other library as dependencies is required if we want to install NVIDIA driver via runfile. We need to install this dependencies first.
$ sudo apt-get install build-essential gcc-multilib dkms
Blacklist the Nouveau Driver
$ sudo nano /etc/modprobe.d/blacklist-nouveau.conf with this content: blacklist nouveau options nouveau modeset=0 and then run this command $ sudo update-initramfs -u $ sudo reboot
Stop gdm Service
After reboot/restart, open console from login page (ctrl+alt+f2). and stop the gdm service (Ubuntu 18.04 by default using gdm as dekstop manager) using this command
$ sudo systemctl stop gdm
Run the Installer
Enter the directory where you saved the downloaded NVIDIA driver installer, and run this command.
$ chmod +x NVIDIA-Linux-x86_64-418.56.run the file name should follow your installer file. then we can run this installer with this command. $ sudo ./NVIDIA-Linux-x86_64-418.56.run --dkms -s
Where, -s is for silent installation, and –dkms is used for register dkms module into the kernel. Before finish the installation, usually the installer will ask you to set a password to turn off the secure boot. Just follow their instruction and reboot the machine.
Check the Installation
you just need to run this command to check if your NVIDIA driver is successfully installed.
Thank you, hopes it help you.