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.57.08.run -x &&
cd NVIDIA-Linux-x86_64-575.57.08
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.
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, set the
NVIDIA_KERNEL_TYPE
variable:
export NVIDIA_KERNEL_TYPE="kernel-open"
If you are going to instead build the proprietary kernel modules, set the
NVIDIA_KERNEL_TYPE
variable:
export NVIDIA_KERNEL_TYPE="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 commands
below (the commands below will navigate to the right directory
based on what NVIDIA_KERNEL_TYPE
is set
to):
pushd $NVIDIA_KERNEL_TYPE &&
make NV_EXCLUDE_KERNEL_MODULES=
Note
You may encounter various build failures. This usually happens
because the kernel version you're using is “too high.” If this
happens, it may be necessary to downgrade the kernel to a lower
version. 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 version to use with this
driver is mentioned to ensure that a build failure does not
occur. The current kernel version used for kernel parameters and
such in this book is linux-6.15.
Important
When you update the kernel, you will also need to reinstall the
NVIDIA kernel modules.
This is because there is glue when kernel modules are built. This
glue doesn't matter too much with first party modules (modules in
the kernel source tree) as the modules are updated at the same
time the kernel is. At that point, there is new glue holding them
together. However, when it comes to third party modules, they
aren't updated when the kernel updates, so this glue the third
party modules had on the kernel breaks. This leads to broken
kernel modules. This also applies if you stay on the same kernel
version but change some options, this can also break the glue.
Be sure that when you reinstall the kernel modules, make sure you
are using the new kernel and have the kernel source you built
from. Otherwise the modules will fail to build.
When you upgrade the kernel, you will not have to reinstall the
driver software, just the kernel modules.
Now as the root
user:
for mod in nvidia{,-drm,-modeset,-peermem,-uvm}; do
rm -vf /usr/lib/modules/$(uname -r)/kernel/drivers/video/$mod.ko
done
make modules_install &&
popd
Install the firmware as the root
user:
rm -rvf /usr/lib/firmware/nvidia/[0-9]* &&
mkdir -pv /usr/lib/firmware/nvidia/575.57.08 &&
cp -v firmware/*.bin /usr/lib/firmware/nvidia/575.57.08
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
/usr/lib/modprobe.d/nvidia.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.
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.
As the root
user, create the file
/usr/lib/modprobe.d/nouveau.conf
to
blacklist Nouveau and NVIDIAFB:
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
# 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
When the GPU sleeps/hibernates, it will lose all memory
allocations by default. You can prevent this by setting two
options for the NVIDIA module as the root
user:
cat > /usr/lib/modprobe.d/nvidia.conf << "EOF"
# Begin /usr/lib/modprobe.d/nvidia.conf
options nvidia NVreg_PreserveVideoMemoryAllocations=1
options nvidia NVreg_TemporaryFilePath=/var/tmp
# End /usr/lib/modprobe.d/nvidia.conf
EOF
Furthermore, this driver does not install DRI drivers or driver
stubs. Likewise, it does not install a pkg-config 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.17. 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.57.08
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.2 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.