Preparing for the NVIDIA Installation
First enable XFree86 DRI and Nouveau support in the kernel and recompile if
necessary.
Device Drivers --->
Graphics support --->
<*/M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) --->
... [DRM]
<M> Nouveau (NVIDIA) cards [DRM_NOUVEAU]
Frame buffer Devices --->
<M> nVidia Framebuffer Support [FB_NVIDIA]
< /M> Simple framebuffer support [FB_SIMPLE]
Important
Build these drivers as kernel modules so that they can properly
be blacklisted.
Extract the NVIDIA driver runfile
and navigate to the extracted directory:
sh NVIDIA-Linux-x86_64-575.64.03.run -x &&
cd NVIDIA-Linux-x86_64-575.64.03
Installation of the NVIDIA Kernel Modules
Note
Building the kernel modules in a chroot will likely cause a build
failure. It is heavily recommended to build them when booted in
the LFS target to avoid uname
-r reporting the kernel version of the host
rather than the target leading to build files being unable to be
found. This can be worked around by specifying KERNEL_UNAME=<x.x.x>
in the
make command which
will override the kernel version to build against. The kernel
version must have already been built for this to work.
Now you will need to build the kernel modules for the driver. There
are two types: open and
proprietary. If you have
the NVIDIA Grace Hopper or NVIDIA Blackwell cards, you must compile
the open kernel modules.
If you have a Turing, Ampere, Ada Lovelace, or Hopper card, it is
recommended to now build the open kernel modules. If you have a
Maxwell, Pascal, or Volta card, build the proprietary kernel modules. If you
are using both an older and newer card, but not the newest cards,
build the proprietary
kernel modules.
If you are going to build the open kernel modules, navigate to the
kernel-open
directory:
cd kernel-open
If you are going to instead build the proprietary kernel modules, navigate
to the kernel
directory:
cd kernel
There will be 5 or 6 kernel modules that will be built. Depending
on your use case, you can skip building a module or two. The UVM
(Unified Virtual Memory) module is for use with CUDA.
If you won't use it, nor wish to use its capabilities, you can skip
building the UVM kernel module. There is also the PeerMem module
which is for datacenters. For gaming, it can safely be disabled.
For UVM, the module is named nvidia-uvm
. For PeerMem, it will be named
nvidia-peermem
. To skip these,
add the module names to the NV_EXCLUDE_KERNEL_MODULES
for the make command. The variable should
be seperated, as such: NV_EXCLUDE_KERNEL_MODULES="nvidia-uvm
nvidia-peermem"
. The make command will have the
variable set to nothing. Add to it as you see fit.
Now build the kernel modules by running the following command:
make NV_EXCLUDE_KERNEL_MODULES=
Note
You may encounter various build failures. This usually happens
because the kernel version is incompatible with the current
kernel version. If this happens, in most cases this is 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. The kernel version used
for kernel parameters and such in this book is linux-6.15.5. As
of now, there are no option mismatches.
Important
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 a 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.
When you rebuild/upgrade the kernel against the same NVIDIA
driver version, you will only need to reinstall the kernel
modules. You will have to reinstall the driver software as well
if you are upgrading from a previous driver version.
Now as the root
user:
make modules_install &&
cd ..
Install the firmware as the root
user:
rm -rvf /usr/lib/firmware/nvidia/[0-9]* &&
mkdir -pv /usr/lib/firmware/nvidia/575.64.03 &&
cp -v firmware/*.bin /usr/lib/firmware/nvidia/575.64.03
Finally, unset the NVIDIA_KERNEL_TYPE
variable:
unset NVIDIA_KERNEL_TYPE
Installing the NVIDIA Driver Software
Install the install script and manifest file for the script as the
root
user:
mkdir -pv /usr/share/nvidia &&
install -vm755 ../install-NVIDIA-1 \
/usr/sbin/nvidia-install &&
install -vm644 ../manifest-NVIDIA-1 \
/usr/share/nvidia/manifest
Now see what options there are and what you want to install by
running /sbin/nvidia-install
--help.
If you want to do the default installation, you can just run the
following command as the root
user:
/sbin/nvidia-install
Important
If you are booted into the system you are running the commands
for, doing so for the above command in a graphical environment
may crash that environment and drop you back to a TTY. Don't do
that, just run it from a TTY or in a chroot where the display
doesn't rely on the libraries provided from this driver. As for
the TTY, it is actually driven by the kernel or its modules, not
the libraries. That is why running the above command in a TTY is
safe—it doesn't overwrite the kernel modules.
Configuring NVIDIA
Config Files
/usr/lib/modprobe.d/nouveau.conf
/usr/lib/modprobe.d/nvidia_drm.conf
List of Packages With Issues
Using this driver can come with compromises. So far, these issues
seem limited to Wayland, desktop environments, and display
managers. The list below documents the known packages that have
issues with this driver.
-
GDM: Using this package on SysVinit systems will result
in failure as GDM does not want to use Wayland for NVIDIA
GPUs, but a permission issue with SysV prevents X11 from
being used. You must launch
Mutter or
gnome-session through the terminal instead. Read the
Mutter entry.
-
gnome-session: This must be launched via a TTY or a
display manager other than GDM for now on SysVinit systems.
-
Mutter: Compile this package with -D wayland_eglstream=true
and
-D egl_device=true
to enable launching with Wayland. Ensure the NVIDIA EGL Libraries are
installed.
On SysVinit systems, Mutter can only be launched via a TTY
or a display manager other than GDM as of now.
-
Xorg-Server-21.1.18: 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.
Configuration Information
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
The DRM kernel module does not use modesetting by default which
is needed by Wayland compositors. Make it use modesetting as the
root
user:
cat > /usr/lib/modprobe.d/nvidia_drm.conf << "EOF"
# Begin /usr/lib/modprobe.d/nvidia_drm.conf
options nvidia_drm modeset=1
# End /usr/lib/modprobe.d/nvidia_drm.conf
EOF
This driver does not install DRI drivers or driver stubs. Likewise, it
does not install a pkgconf file
saying where to find the associated files. The files aren't
needed with this driver. However, some applications expect the
pkg-config file to exist, namely
Xorg-Server-21.1.18. Create one now as
the root
user:
cat > /usr/lib/pkgconfig/dri.pc << "EOF"
prefix=/usr
includedir=${prefix}/include
dridriverdir=/usr/lib/dri
Name: dri
Description: Direct Rendering Infrastructure
Version: 575.64.03
Requires.private: libdrm >= 2.4.109
Cflags: -I${includedir}
EOF
Applications that do require this file typically will not link
against any library in /usr/lib/dri
. If you are worried that an
application will try to link against non-existent libraries, you
can compile Mesa-25.1.5 to get these libraries and a real
pkg-config file. Note that those
libraries will not be used when this driver is in use.
Note
You should skip to XCB Utils after you are done with this page
unless you wish to install extra software.