Simplifying NVIDIA driver installation on Ubuntu

NVIDIA Drivers Made Easy

Article from Issue 257/2022

A terminal-based solution helps ease the frustration of installing NVIDIA drivers.

Proprietary NVIDIA [1] drivers on Linux are an evil so necessary that even the staunchest of open source advocates will find a use case for them from time to time. Whether for gaming, mining, or some other hardware-accelerated task, the green giant is here to stay, for better or for worse, and sadly seems to be wholeheartedly opposed to going all in with open source. Unlike AMD [2] driver support – which is simply fantastic on Linux, as I am sure most of you know already – NVIDIA doesn't seem to be willing to play nicely. One has to wonder if they feel that they simply don't need to, that their sway over the market sets them apart from others and absolves them of the responsibility that the other players feel to their customers. Who knows. What I do know is that NVIDIA Linux driver support is worse for the wear despite the hard work of many folks in the community. The worst part about this is the effect that it has on beginners to Linux who have heard all of the wonderful things about it and give it a try, only to have their system either hobbled with Nouveau drivers or who have to go through what I am about to discuss below. It is a sad state with a clear and obvious solution that I am afraid we won't see come to fruition any time soon.

All may not be well, but not all is bad either. At least we have some kind of (albeit proprietary) solution to rely upon.

I will focus on Ubuntu [3] here as that is what I typically use nowadays as a simple, Linux-based install for whatever I need to do, but also because this is statistically likely to be what a beginner would first try out. While I started with Red Hat [4] (pre-Fedora [5]), today most folks tend towards Ubuntu, a derivative of it, or perhaps another Debian derivative their first time out.

While Ubuntu itself has a driver's install section, not all Ubuntu derivatives necessarily do, and in some cases, even if your distribution does have an advanced driver install section, it may be difficult to find, especially for a beginner. Furthermore, there may be confusion about which group of packages to install and which version of the NVIDIA proprietary driver you want to use. I have personally also found that often after choosing a driver and clicking on Apply, the window becomes unresponsive, or at least appears that way. While the basic open source Nouveau [6] Linux driver is adequate for most tasks, hard-core users will often find a need for proprietary drivers. While I can't fix the terribly dated control panel interface that NVIDIA offers in their proprietary driver package installation, I can help you get it installed and walk you through how to deal with it when that install inevitably breaks.

In this article I'll show you how to figure out which graphics drivers to use on Ubuntu Linux and derivatives with a simple, built-in command which I find quicker and easier than opening up the GUI equivalent. I will also show you how to deal with the near certainty of the black screen that you'll encounter afterwards. You see, much like a YouTuber trying to install Steam [7] on Pop!_OS [8] for the first time, I too have had struggles with using the GUI for installing NVIDIA drivers. However, unlike the typical YouTuber [9], I have not had any issues doing the same task in the terminal.

It should be noted that more than one package may exist for NVIDIA proprietary drivers, and you may need to test a few different driver packages before you figure out which one works best for you. Furthermore, devices with Optimus [10] capability may or may not work properly in terms of Optimus switching. For those who don't know, don't recall, or weren't around in those days, Optimus is an NVIDIA and Intel [11] software scheme intended to allow the user to choose between NVIDIA or Intel graphics at will within the OS itself. While packages from the likes of system76 and others do make Optimus more capable than it was when it was first introduced, and in many cases fully functional, there still tend to be bugs in my experience. Don't let that deter you, though, from trying some of the different packages out there for your particular NVIDIA card and Intel iGPU combo. However, Optimus itself isn't something that I intend to get into here.

Everything that I will outline here was done on a Supermicro X8STi [12] with an entry-level NVIDIA GeForce GT 710 in the single PCIe X16 slot. (I have done the same on my Dell E6430 [13] with an NVS 5200M and Intel iGPU and have actually gotten Optimus to work in the past; though again, that is not something that I intend to go over here for the reasons already mentioned.) If your machine has NVIDIA and Intel, my suggestion is to simply install the NVIDIA drivers and use the NVIDIA card. For me, there was no advantage to having Optimus working, because the battery was already shot and I was better off simply running NVIDIA full time on that machine for the performance, regardless of the electron abuse. Let's go over how to find and install the correct drivers and deal with whatever aftermath may exist.

Determining System Component Information

Once you have the machine up and running, you can check which drivers are being used by simply running the following:

$ lspci -vv

This will show all of your PCI devices with details included (Figure 1). If you scroll down a bit, you will see one listed as VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 710], with the particulars of your card listed here, instead of GT 710, obviously. When you look at the last two lines of that entry you will see Kernel driver in use and Kernel modules. Here you will see nouveau listed as the kernel driver in use, which, as mentioned, is the basic open source NVIDIA driver. If you are running Pop!_OS or a similar distribution which came with the proprietary NVIDIA drivers preinstalled, then you may see nvidia listed under Kernel driver in use, in which case this article isn't for you, but most of you will likely see nouveau. As a side note, after Capabilities you will see access denied. To see this field, simply run the same command with sudo and you will have access to that information. This will give some additional information, such as power management, but isn't needed for what we are doing.

Figure 1: Terminal output of the lspci -vv command.

Finding Out What Driver Packages Are Available

At this point you have confirmed that the card was recognized and is running with the open source driver. To view which proprietary NVIDIA driver packages are available, you will want to run the following command now:

$ ubuntu-drivers devices

This will take a few seconds depending on your system. For me, it normally returns a complete response in about 15 seconds (Figure 2), so be patient here. My setup returns the following:

== /sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0 ==
modalias : pci:v000010DEd0000128Bsv00001462sd00008C93bc03sc00i00
vendor   : NVIDIA Corporation
model    : GK208B [GeForce GT 710]
driver   : nvidia-driver-460 - distro non-free
driver   : nvidia-driver-470 - distro non-free recommended
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-460-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin
Figure 2: Terminal output of the ubuntu-drivers devices command.

As you can see here, there is more than one package available from NVIDIA along with the Nouveau open source driver. You can double check if your system has any NVIDIA packages installed by running:

$ apt list *nvidia* --installed

If you have installed any of these, they will be listed along with any dependencies that are required for them to run which are also present on your system, such as libraries and the settings dialog box package (Figure 3).

Figure 3: Terminal output of the apt list command.

It is here that things can sometimes get a bit difficult. While all of these packages are available for your card, not all of them will work well, properly, or for that matter, at all, with your specific card. With that in mind you should at this point back up everything that you need to save somewhere safe and on a different machine, external drive, cloud storage, or (better yet) all of the above. Personally, I know that with my GT 710 the best functioning package is listed as nvidia-driver-390, though frankly, I only know that through trial and error. Documentation on these packages is good and you can find more information about them at the NVIDIA website [1]. Personally, I had to learn this the hard way, by trying a package, uninstalling it when it failed, trying a different package, rinse and repeat. For that reason I would like to give a bit of a disclaimer here: If you install one of these packages and reboot to a black screen or have some other problem with your display, then be patient and don't fret just yet.

Device Driver Installation

To install the package that you would like to try, simply run:

$ sudo apt update
$ sudo apt install nvidia-driver-390

replacing the nvidia-driver-390 with the package of your choice for your specific GPU. Using the terminal here has the advantage that you can easily see what is going on, as opposed to using the GUI, which often leaves one wondering. Once the installation is completed and all dependencies have been installed, you will want to reboot your machine so the new software can be loaded at boot. If you are lucky, you will be greeted with the login screen or desktop as you normally would. You can then check that your installation worked by either using the lspci -vv command discussed earlier or by opening settings and looking at the About section to see what is listed for Graphics. Mine shows GeForce GT 710/PCIe/SSE2 while using the nvidia-driver-390 packages. As mentioned before, using lspci -vv will show nvidia under the Kernel driver in use section. You will also have the NVIDIA control panel installed for changing the particulars of your setup with a graphical interface.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More