Install Nvidia Drivers on Ubuntu via CLI
A situation might exist where you want to install NVIDIA drivers on a server that has no desktop experience. This is usually for AI, LLM, transcode or render farms, maybe you have a media server that needs some help recomposing media for streaming, for example Ollama, Jellyfin, Plex and Emby use this type of facility.
In these cases, the latest NVIDIA driver needs to be installed rather than the driver included with the Ubuntu distribution and of course, the distribution should not be allowed to “update” the driver in the future when an update is applied.
In this post, an Ubuntu server with an NVIDIA graphics card will get the official drivers installed and the distribution drivers will be banned by you.
0 . Latest updates and prerequisites.
2023.09.17 – First draft, Ubuntu 22.04 Server.
Check back for updates, if you run into trouble. Leave a comment if the post is missing some detail.
You need root or sudo access to make changes to drivers. Internet access is preferred (you need to get the files to the server, somehow, with a tool like WinSCP).
1 . Check what hardware and software is already there.
The lspci package will list all the hardware the system is aware of and the output can be piped to “grep” to search for the VGA card/s in the server (case-sensitivity is important, here):
admin@server40:~$ lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 730] (rev a1)By default, Ubuntu will install Nouveau drivers, the open source NVIDIA alternative, however applications such as media servers will benefit from proprietary drivers. Some distributions will also install an older or more consumer friendly version of the proprietary drivers. The trouble here is that media services and render farms, usually use specific features and the latest card drivers are preferred.
To see what drivers are installed for the above card, check what modules are loaded for the “video” device with “lsmod” and grep for the devices named “video”:
admin@server40:~$ lsmod | grep video
video 65536 1 nouveauAbove, you can see the Nouveau drivers are installed.
2 . Download and install the official drivers.
On the NVIDIA website, you can see the latest version for the specific card (an old GT730) installed is 470.x.
While I feel a little disappointed by the low version number, the release date is a little recent, so lets go with that.
The download button gives a file that needs to be copied to a temporary location on the server. WinSCP is a great package to help with this if your admin workstation is a Windows based computer, or use scp from the command line.
Since a kernel module will be built, some dependencies are required at the server:
sudo apt install dkms build-essential linux-headers-genericSet the downloaded file to executable:
admin@server40:/tmp$ chmod +x NVIDIA-Linux-x86_64-470.199.02.runRun the installer:
admin@server40:/tmp$ sudo ./NVIDIA-Linux-x86_64-470.199.02.runDuring the installation, you will be prompted to block the Nouveau driver, accept this:
One or more modprobe configuration files to disable Nouveau have been written. For some distributions, this may be sufficient to disable Nouveau; other distributions may require modification of the initial ramdisk.
Please reboot your system and attempt NVIDIA driver installation again. Note if you later wish to re-enable Nouveau, you will need to delete these files: /usr/lib/modprobe.d/nvidia-installer-disable-nouveau.conf,
/etc/modprobe.d/nvidia-installer-disable-nouveau.confThe installer will exit and prompt you to reboot, however, the Nouveau driver will still load when the system restarts since it is attached to the kernel. Disable this link by regenerating the kernel and then rebooting, again:
admin@server40:/tmp$ sudo update-initramfs -u
admin@server40:/tmp$ sudo rebootYou can check the Nouveau driver is blocked when the system restarts with lsmod, as above:
admin@server40:~$ lsmod | grep videoNothing is returned, so no driver is loaded and you also know now the driver will not install itself at restart, anymore. Re-run the Nvidia installer:
admin@server40:/tmp$ sudo ./NVIDIA-Linux-x86_64-470.199.02.runRestart the server and check the Nvidia drivers are loaded:
admin@server40:~$ lsmod | grep nvidia
nvidia_drm 65536 0
nvidia_modeset 1200128 1 nvidia_drm
nvidia 35512320 1 nvidia_modeset
drm_kms_helper 311296 1 nvidia_drm
drm 622592 4 drm_kms_helper,nvidia,nvidia_drmThe Nvidia driver comes with a utility to query the card and is the ultimate test to see if the driver is loaded and functional, “nvidia-smi”:
admin@server40:~$ nvidia-smi
Sun Sep 17 10:22:18 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.199.02 Driver Version: 470.199.02 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 N/A | N/A |
| 30% 48C P0 N/A / N/A | 0MiB / 2000MiB | N/A Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
3 . Block the operating system from making changes.
Somewhere in the /etc/modprobe.d/ file list, a file should exist that contains the following lines:
blacklist nouveau
options nouveau modeset=0
The NVIDIA installer created this in /etc/modprobe.d/nvidia-installer-disable-nouveau.conf:
admin@server40:~$ cat /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0
The Nouveau driver should not automatically re-install and usually, to install the Ubuntu distribution driver, some permissions must be sought for accepting terms and conditions. So, in a perfect world, the operating system will not reinstall the Nouveau driver or the driver distributed with the operating system, however, any updates to the kernel in the future may require the NVIDIA driver to be reinstalled.
4 . Supporting this blog.
his type of content takes a lot of effort to write. Each post is drafted, researched, then tested multiple times, even a simple step or detail might take more than a few hours to go from the idea to a published blog post.
If you feel I have saved you some time, you can support me by;
- hosting with DigitalOcean, like I do – DigitalOcean.
- buying me a beer through PayPal – PayPal.
© HorseFreeGlue, 2025. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibitedund Wehsling and aardvark.systems with appropriate and specific direction to the original content.