Sudo apt install nvidia-driver? Ubuntu NVIDIA install
In this article
Yes, you can install NVIDIA drivers on Ubuntu using the command sudo apt install nvidia-driver. This pulls the latest driver package from Ubuntu’s official repositories and configures it for your system.
Background: What Are NVIDIA Drivers?
NVIDIA drivers are software layers that translate operating‑system calls into commands that the graphics hardware can execute. They provide hardware acceleration for 3D rendering, video decoding, and compute workloads. Ubuntu ships with a free, open‑source driver called nouveau, which works for basic tasks but lacks full performance and feature support. The proprietary NVIDIA driver, released by NVIDIA, unlocks the full capability of modern GPUs, including CUDA, Vulkan, and advanced power‑management features.
How sudo apt install nvidia-driver Works
The apt package manager contacts Ubuntu’s repositories, resolves dependencies, and downloads the driver package that matches your kernel and GPU model. The installation process includes:
- Package selection: The meta‑package
nvidia-driverpoints to the newest stable driver series (e.g., 535). It automatically pulls in the correct binary package for your architecture. - Kernel module installation: The driver package installs a kernel module (
nvidia.ko) that hooks into the Linux kernel. - Configuration: The installer updates Xorg configuration files, creates a
nvidia.conffile, and registers the driver with the display server. - Post‑install scripts: Scripts run to enable secure boot signatures if you have Secure Boot enabled, and to add your user to the
videogroup.
After installation, a reboot is required so the new kernel module loads and the display server can use the GPU.
Choosing the Right Driver Version
Ubuntu’s default nvidia-driver meta‑package always points to the most recent stable release. In many cases that is the best choice, but there are scenarios where a specific version is preferable:
- Gaming and high‑end graphics: The latest driver often provides performance improvements for the newest games and APIs.
- CUDA development: Certain CUDA toolkits require a specific driver version; check the CUDA documentation for compatibility.
- Stability on older hardware: Older GPUs (e.g., GeForce 8/9 series) may work better with a legacy driver series such as 390 or 410.
- Enterprise or GPU‑compute workloads: Some professional workflows recommend the long‑term support (LTS) driver series available in Ubuntu’s
ubuntu-driverstool.
To see available driver candidates, run:
ubuntu-drivers devices
This lists recommended drivers, legacy options, and the current status of the nouveau driver. If you need a specific version, install it directly, e.g., sudo apt install nvidia-driver-470.
Common Problems and Troubleshooting
Even with a straightforward install, users sometimes encounter issues. Below are frequent problems and practical fixes.
- Black screen or Xorg crash after reboot: The kernel module may not load because the kernel version changed during an update. Run
sudo apt update && sudo apt full-upgradeto ensure all packages match the current kernel, then reboot. - Secure Boot interference: If Secure Boot is enabled, the unsigned NVIDIA module will not load. During installation, you’ll be prompted to enroll a MOK (Machine Owner Key). Follow the on‑screen instructions, reboot, and sign the module.
- Conflict with
nouveau: The open‑source driver can remain loaded if not blacklisted. Verify/etc/modprobe.d/blacklist-nouveau.confcontainsblacklist nouveauand runsudo update-initramfs -u. - Outdated kernel or missing headers: The driver package requires matching kernel headers. Install them with
sudo apt install linux-headers-$(uname -r)before installing the driver. - CUDA toolkit not found: After installing the driver, add
/usr/local/cuda-version/binto yourPATHandLD_LIBRARY_PATHto use the toolkit.
Alternatives and Comparison
There are two main driver options for NVIDIA GPUs on Ubuntu:
- Proprietary NVIDIA driver (recommended) – Full feature set, best performance, support for CUDA, OpenGL, Vulkan, and advanced power management.
- Open‑source
nouveaudriver – Included by default, no extra installation, but limited performance and missing features such as hardware‑accelerated video decoding and compute APIs.
For most users, the proprietary driver is the default choice. nouveau may be suitable for low‑power laptops or for users who prefer a fully open‑source stack and are willing to accept reduced performance.
Safety and Best Practices
When installing or updating NVIDIA drivers, follow these guidelines to avoid system instability:
- Keep the system updated: Run
sudo apt update && sudo apt upgraderegularly to keep kernel and driver packages in sync. - Use the official Ubuntu repositories: Avoid third‑party PPAs unless you have a specific reason, as they can introduce incompatible binaries.
- Backup Xorg configuration: Before installing a new driver, copy
/etc/X11/xorg.confif it exists. A misconfigured file can prevent the display server from starting. - Reboot after kernel upgrades: A new kernel may require a new driver module. Reboot after any kernel change to load the appropriate module.
- Test in a live session: If you’re unsure about the driver, boot from a Ubuntu live USB and try the proprietary driver in a temporary session before committing to a full install.
- Check hardware compatibility: Very old GPUs (pre‑Kepler) are no longer supported by recent driver releases. Verify your GPU model against NVIDIA’s supported list.
Frequently Asked Questions
What if my GPU is not listed in ubuntu-drivers devices?
Older or very new GPUs may not appear in the default list. Use lspci -nn | grep -i nvidia to confirm the device ID, then search NVIDIA’s website for the appropriate driver series and install the corresponding package manually.
Can I install multiple NVIDIA driver versions side by side?
Ubuntu’s package system does not support parallel driver installations. If you need to switch between versions, remove the current driver with sudo apt remove nvidia-driver and install the desired version.
Why does my display go black after installing the driver?
Common causes are a mismatched kernel header, Secure Boot blocking the module, or a leftover nouveau module. Ensure headers match, enroll the MOK key, and blacklist nouveau.
Do I need to reinstall the driver after a kernel upgrade?
Yes. Kernel upgrades replace the module interface, so the driver must be recompiled or reinstalled to match the new kernel. Running sudo apt install --reinstall nvidia-driver after an upgrade is a quick fix.
Is there a way to keep the driver up to date automatically?
Ubuntu’s ubuntu-drivers autoinstall command installs the recommended driver and keeps it updated through normal package upgrades. For bleeding‑edge features, you can add the NVIDIA PPA and let apt handle updates.