Build your own NVIDIA modules using the DKMS package¶
By using the Dynamic Kernel Module Support (DKMS) driver package, you can build the NVIDIA driver for the exact kernel that you’re running. This is useful when you’re using a custom kernel or when the standard NVIDIA packages are missing or lagging in release.
Warning
We don’t recommend using the DKMS modules unless you are running a custom kernel for which the prebuilt drivers are not supported. This is because the DKMS drivers are not signed with Canonical’s key and thus do not support Secure Boot.
For most Ubuntu users, we recommend following the more automated Install NVIDIA drivers guide instead.
Types of NVIDIA drivers¶
We package two types of NVIDIA drivers:
- Unified Driver Architecture (UDA) drivers
These are recommended for the generic desktop use and gaming. They also support computing use cases such as AI and machine learning. You can also find them on the NVIDIA website.
- Enterprise Ready Drivers (ERD)
These are recommended on servers and for computing tasks. These drivers come from an NVIDIA release branch that’s qualified and supported for longer on data center GPUs. They omit certain desktop-oriented features. Their packages can be recognized by the
-serversuffix. You can read more about these drivers in the NVIDIA documentation.
Additionally, Ubuntu provides the NVIDIA Fabric Manager and the NVSwitch Configuration and Query (NSCQ) library, which you will only need if you have NVSwitch hardware. The Fabric Manager and NSCQ library are only available with the ERDs or -server driver versions.
Install the kernel modules¶
The general procedure is to install the relevant NVIDIA DKMS package and linux-headers to build the kernel modules, and enroll your own key to sign the modules.
Install the
linux-headersmetapackage for your kernel flavor (e.g.generic,lowlatency, etc.):$Check that the headers for your specific kernel were installed by the metapackage:
$If the headers for your current running kernel were not installed, install them by specifying the running kernel version:
$Install the NVIDIA DKMS package for your desired driver series:
$This may automatically guide you through creating and enrolling a new key for Secure Boot.
Alternatively, you can use
ubuntu-driversto automatically select an appropriate DKMS driver branch:$
Install the user-space drivers and the driver libraries¶
After installing the correct kernel modules, install the correct driver metapackage:
$If your system comes with NVSwitch hardware, install Fabric Manager and the NVSwitch Configuration and Query library:
$
Switch between pre-compiled and DKMS modules¶
You can switch from the pre-compiled NVIDIA drivers to the DKMS modules or the other way around.
Remove all existing NVIDIA packages from your system:
$If you are unsure which
${DRIVER_BRANCH}to pick for removal, you might look at the installed nvidia packages and see the different${DRIVER_BRANCH}numbers that are present on your system.Since
autoremovewill take care of all indirect dependencies, it is sufficient to list those that have been directly installed by usingapt-mark.$Remove any additional packages that may have been installed as a dependency (e.g. the
i386libraries onamd64systems) and which were not caught by the previous command:$Install new drivers:
To install the pre-compiled drivers, refer to Install NVIDIA drivers.
To install the DKMS modules, go back to Build your own NVIDIA modules using the DKMS package.