The NVIDIA proprietary driver contains firmware, kernel drivers, userland drivers pertaining to OpenGL, Vulkan, and hardware acceleration, and provides useful utilities for Turing and later NVIDIA cards.
Recommended kernel version(s) to use: linux 6.17.x - 7.0.x
Download: https://us.download.nvidia.com/XFree86/Linux-x86_64/595.71.05/NVIDIA-Linux-x86_64-595.71.05.run
CUDA-13.2.1 (for building in direct CUDA support into various packages like FFmpeg or OBS-Studio; install after following this page)
GTK-3 (for nvidia-settings; install after following this page)
NVIDIA-VA-API-Driver-0.0.17 (for VA-API support; install after following this page)
OpenCL-SDK-2025.07.22 (for using the OpenCL drivers)
Vulkan-SDK-1.4.350.0 (for using the Vulkan drivers)
Wayland-1.25.0 (needed for Wayland support)
Xorg-Server-21.1.22 (required for running nvidia-xconfig, like in What Now?; install after following this page)
Install the NVIDIA driver by running the following command as the
root user:
sh NVIDIA-Linux-x86_64-595.71.05.run -z \
-j $(nproc) \
-k `uname -r` \
--no-peermem \
--override-file-type-destination=OPENCL_WRAPPER_LIB:/tmp/nvidia \
--override-file-type-destination=OPENCL_WRAPPER_SYMLINK:/tmp/nvidia
-z: This parameter disables
checking to see if the nouveau kernel
driver is loaded, which may be if nouveau isn't blacklisted by modprobe yet. Otherwise, the
driver will complain.
-j $(nproc): This works
like how MAKEFLAGS is set up. The
concurrency is capped out unless this parameter is used.
-k : This parameter sets the kernel
version/name the NVIDIA driver should build against. `uname
-r` is used, which mimicks the behavior of the
driver and most third-party kernel module build systems. This is
necessary if the kernel version/name you want NVIDIA to build
against differs from what uname
-r reports. For example, if you want to build
against `uname
-r`7.0.11 but uname -r reports 6.19.12, you must use -k 7.0.11. uname -r reports what the host
kernel is being used, which can pose issues in a chroot. `command` is used to return the
output of a command, so if 7.0.11 is
given, you should remove the backticks since that string is not a
command. If you want to build against something like 7.1, where it is a new minor or major version but
isn't a bugfix release, .0 must be
suffixed so it would look like 7.1.0.
To see what kernel names/versions are available to build against,
look in the /usr/lib/modules
directory.
--no-peermem: This
parameter disables building the peermem (or NVIDIA Peer Memory) kernel module.
It's used for datacenters. Using -A on
its own will show you which exact devices the Peer Memory kernel
module covers. If you need it, remove this parameter.
--override...=OPENCL_WRAPPER...:/tmp/nvidia:
These parameters disable installing the NVIDIA OpenCL ICD loader in
favor of OpenCL-SDK-2025.07.22, which is more
generic and supports the NVIDIA OpenCL drivers. If 32-bit
compatibility libraries are being installed, the driver will warn
multiple times that the libOpenCL
library exists. Keep agreeing to continue the installation.
--print-recommended-kernel-module-type:
When used, the driver will tell you which kernel module type is
recommended, then exit. It is recommended to use this if you're
unfamiliar with installing the NVIDIA driver via the runfile.
Afterwards, install the driver normally then choose the recommended
kernel module type when prompted.
-A: This option is used to give all the
options that you can use to tune how the installation of the driver
will be handled.
The driver may ask you multiple questions, output various warnings, and generally say a lot. Just go through the prompts.
The source code you built the kernel from must be in the same
location you built the kernel. For example, if you built the
kernel in /sources/linux-6.16.1,
the source code should stay there and must not be deleted until
the third party modules have been built. Some Linux distributions
get around this by installing development files in /usr/src or use DKMS, but that is out of the
scope of this book.
You may encounter various build failures. This usually happens because the module code is incompatible with the current kernel version. If this happens, in most cases it can be fixed by downgrading the kernel. When a new driver release happens, the driver will then most likely support the kernel version at the time. At the top of this section, the recommended kernel series to use with this driver is mentioned to give an idea of what is the idea kernel version to build against.
When you rebuild/upgrade the kernel, you will also need to reinstall the NVIDIA kernel modules.
Kernel modules are installed in a versioned directory that, when they are built against a different kernel version, will no longer match the booted kernel version and cannot be used. Furthermore, there is glue built, so any changes to the kernel can break that glue. For kernel modules in the Linux source tree, known as first party modules, they get updated and rebuilt alongside the kernel, so issues aren't ran into for first-party modules. Third party modules aren't, however, and need to be updated/rebuilt.
If you updated or changed the kernel (via different options) where the NVIDIA driver was built against it, you will have to reinstall the driver.
Using this driver can come with compromises. So far, these issues seem to be limited to Wayland and window managers. The list below documents the known packages that have issues with this driver.
Mutter: Compile this package by applying patches and sed commands mentioned in BLFS first, then run the proceeding commands:
find -name \*.c \
-exec sed -i '/<EGL\/eglmesaext.h>/d' {} \; &&
find -name \*.h \
-exec sed -i '/<EGL\/eglmesaext.h>/d' {} \; &&
mkdir build &&
cd build &&
meson setup --prefix=/usr \
--buildtype=release \
-D tests=disabled \
-D profiler=false \
-D bash_completion=false \
-D wayland_eglstream=true \
-D egl_device=true \
.. &&
ninja
Install as root with
ninja
install.
Xorg-Server-21.1.22: While this
package works just fine, the TearFree patch and
configuration file will be useless as the Xorg driver
(nvidia_drv) will be used
instead of the modesetting driver. The TearFree patch and
configuration file is modesetting-specific. Thus, you must
find another way to get rid of screen tearing if that is
your wish. Such fixes may bog down performance drastically
such that 144 FPS may drop to 60 FPS.
EGL_EXT Device Query and Enumeration: libglvnd sets up
important extensions part of the EGL specification and are
provided via header files. Those header files offer
function declarations as well, so that their addresses can
be retrieved. NVIDIA's libraries don't offer two
extensions: EGL_EXT_device_query and EGL_EXT_device_enumeration. The driver
does provide function definitions for querying devices via
EGL, however. This means that whenever a package checks for
the extensions explicitly, if Mesa-26.0.1 is not
installed, the package will handle the case for those
extensions being missing, whether or not the functions that
handle device querying actually exist or not.
Most packages don't do this. However, if you encounter such a situation, you must make it so the package does not check for those extensions in order to prevent potential failures. Niri, which uses smithay, suffers from this. This is being attempted to be resolved upstream with smithay. Ideally, NVIDIA should export those extensions. It does not in any way, only provides the functions that make device querying possible.
In order for the drivers to work properly, device nodes must be
created beforehand. Under certain conditions or configurations,
these aren't created automatically when starting a display
server. As the root user, create
a udev rule to always create these nodes at boot time:
mkdir -pv /usr/lib/udev/rules.d &&
cat > /usr/lib/udev/rules.d/60-nvidia.rules << "EOF"
# Always create NVIDIA device nodes at boot time.
ACTION=="add|bind", \
ATTR{vendor}=="0x10de", \
ATTR{class}=="0x03[0-9]*", \
DRIVER=="nvidia", \
TEST!="/dev/nvidiactl", \
RUN+="/usr/bin/nvidia-modprobe", \
RUN+="/usr/bin/nvidia-modprobe -c0 -u"
EOF
Nouveau and NVIDIAFB support was compiled into the kernel to make
the NVIDIA kernel modules build successfully. However, Nouveau
and NVIDIAFB conflict with the NVIDIA kernel modules, so they
should be blacklisted. Furthermore, other modules may have been
built that can conflict, and should likewise be disabled. As the
root user, create the file
/usr/lib/modprobe.d/nouveau.conf to
blacklist Nouveau and NVIDIAFB, as well as other conflicting
modules:
mkdir -pv /usr/lib/modprobe.d &&
cat > /usr/lib/modprobe.d/nouveau.conf << "EOF"
# Begin /usr/lib/modprobe.d/nouveau.conf
blacklist nouveau
blacklist nvidiafb
blacklist nova_core
blacklist nova_drm
# End /usr/lib/modprobe.d/nouveau.conf
EOF
If you installed libglvnd-1.7.0 and libgbm-1.0.7, you should not need Mesa as a dependency for any package in any of the LFS books. You must ensure you install Xorg-Server-21.1.22 and/or Xwayland-24.1.11 from this book as those packages include important patches that get around needing a Mesa-specific interface used for loading Mesa-specific software rendering drivers.
With this Mesa-less setup, you can skip to Chapter 14, X11 and expect smooth sailing. If you want to however, you can also install CUDA in this subsection to help performance, which up to you.