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
Apply a patch for the proprietary kernel module type for the driver
for compatibility with linux-6.15:
pushd kernel &&
patch -Np1 -i ../../nvidia-575.57.08-kernel_gpl_cachyos-1.patch &&
popd
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
Making a NVIDIA Software Installation Script
There is a lot of software this driver provides. A portion of it
depending on your usecase can be safely skipped. To offer
customizability without complexity, the following section is
dedicated to walking you through making a custom install script to
install only what you need.
First make a starter script so that it can be added to:
cat > nvidia-install-soft << "EOF"
#!/bin/sh
# Install script for NVIDIA driver software, not including kernel modules.
# Script modules made by
# The GLFS Development Team, 2024-2025.
EOF
Each subsection of this section will have an explanation of a piece
of the driver you may need. Along with that, it might have two
subsections: a 64-bit and lib32 section. If you're not doing
multilib, you can skip the lib32 sections and only follow the
64-bit ones. Each block of commands will add to the script.
Mandatory Software
Most of this software is needed by other components in this
driver, while the rest of it helps with loading the driver.
cat >> nvidia-install-soft << "EOF"
echo "Installing mandatory software - 64-bit"
mkdir -pv /usr/share/nvidia &&
rm -fv /usr/lib/libnvidia-allocator.so* &&
cp -v libnvidia-cfg.so* \
libnvidia-eglcore.so* \
libnvidia-glcore.so* \
libnvidia-glsi.so* \
libnvidia-glvkspirv.so* \
libnvidia-gpucomp.so* \
libnvidia-ml.so* \
libnvidia-pkcs11* \
libnvidia-rtcore.so* \
libnvidia-tls.so* \
libnvidia-allocator.so* \
/usr/lib &&
ln -svrf /usr/lib/libnvidia-allocator.so* \
/usr/lib/gbm/nvidia-drm_gbm.so &&
cp -v nvidia-modprobe \
/usr/bin &&
cp -v nvidia-application-profiles* \
/usr/share/nvidia &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing mandatory software - lib32"
rm -fv /usr/lib32/libnvidia-allocator.so* &&
cp -v libnvidia-cfg.so* \
libnvidia-eglcore.so* \
libnvidia-glcore.so* \
libnvidia-glsi.so* \
libnvidia-glvkspirv.so* \
libnvidia-gpucomp.so* \
libnvidia-rtcore.so* \
libnvidia-allocator.so* \
/usr/lib32 &&
ln -svrf /usr/lib32/libnvidia-allocator.so* \
/usr/lib32/gbm/nvidia-drm_gbm.so &&
EOF
X11 Drivers
Add to the script if you are going to use Xorg-Server-21.1.16 or Xwayland-24.1.6.
cat >> nvidia-install-soft << "EOF"
echo "Installing X11 drivers - 64-bit"
mkdir -pv /usr/lib/xorg/modules/{drivers,extensions} &&
mkdir -pv /usr/share/X11/xorg.conf.d &&
cp -v nvidia_drv.so* \
/usr/lib/xorg/modules/drivers &&
cp -v libglxserver_nvidia.so* \
/usr/lib/xorg/modules/extensions &&
cp -v libGLX_nvidia.so* \
libnvidia-fbc.so* \
/usr/lib &&
cp -v nvidia-drm-outputclass.conf \
/usr/share/X11/xorg.conf.d &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing X11 drivers - lib32"
cp -v libGLX_nvidia.so* \
libnvidia-fbc.so* \
/usr/lib32 &&
EOF
EGL Drivers
Add to the script if you are going to use EGL (like with
Wayland-1.23.1).
cat >> nvidia-install-soft << "EOF"
echo "Installing EGL drivers - 64-bit"
mkdir -pv /usr/share/glvnd/egl_vendor.d &&
cp -v libnvidia-egl-*.so* \
/usr/lib &&
cp -v libEGL_nvidia.so* \
/usr/lib &&
cp -v libnvidia-wayland* \
/usr/lib &&
cp -v {10,15,20}*.json \
/usr/share/glvnd/egl_vendor.d &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing EGL drivers - lib32"
cp -v libnvidia-egl-*.so* \
/usr/lib32 &&
cp -v libEGL_nvidia.so* \
/usr/lib32 &&
EOF
GLES v2 and v3 Driver
Add to the script if you didn't disable OpenGL ES v2 and v3 in
libglvnd-1.7.0.
cat >> nvidia-install-soft << "EOF"
echo "Installing the GLES v2 and v3 driver - 64-bit"
cp -v libGLESv2_nvidia.so* \
/usr/lib &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing the GLES v2 and v3 driver - lib32"
cp -v libGLESv2_nvidia.so* \
/usr/lib32 &&
EOF
Vulkan Configuration File
Add to the script if you are going to use Vulkan (highly
recommended). A prerequisite is following either the X11 or EGL sections.
cat >> nvidia-install-soft << "EOF"
echo "Installing the Vulkan configuration file"
mkdir -pv /usr/share/vulkan/icd.d &&
cp -v nvidia_icd.json /usr/share/vulkan/icd.d &&
EOF
The Vulkan driver according to the ICD configuration file is
libGLX_nvidia
. If you installed the
EGL drivers, you can make the Vulkan driver use EGL instead of
GLX. This is required if you didn't follow the X11 section. Add to the script if you want
or need to make that change.
cat >> nvidia-install-soft << "EOF"
echo "Making the Vulkan driver use EGL instead of GLX"
sed -i 's/GLX/EGL/' \
/usr/share/vulkan/icd.d/nvidia_icd.json &&
EOF
VDPAU Driver
Add to the script if you installed libvdpau-1.5.
cat >> nvidia-install-soft << "EOF"
echo "Installing the VDPAU driver - 64-bit"
cp -v libvdpau_nvidia.so* \
/usr/lib/vdpau &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing the VDPAU driver - lib32"
cp -v libvdpau_nvidia.so* \
/usr/lib32/vdpau &&
EOF
OpenCL Driver and Loader
Add to the script if you want OpenCL
support. This will also install the OpenCL loader.
cat >> nvidia-install-soft << "EOF"
echo "Installing the OpenCL driver and loader - 64-bit"
cp -v libOpenCL.so* \
/usr/lib &&
cp -v libnvidia-opencl.so* \
/usr/lib &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing the OpenCL driver and loader - lib32"
cp -v libOpenCL.so* \
/usr/lib32 &&
cp -v libnvidia-opencl.so* \
/usr/lib32 &&
EOF
CUDA Drivers
Add to the script if you want to use CUDA
or applications that use it. The software installed also enables
general hardware acceleration and ray tracing.
cat >> nvidia-install-soft << "EOF"
echo "Installing the CUDA drivers - 64-bit"
cp -v libcuda.so* \
libcudadebugger.so* \
libnvidia-api.so* \
libnvidia-encode* \
libnvidia-ptx* \
libnvidia-nvvm* \
libnvcuvid.so* \
/usr/lib &&
EOF
cat >> nvidia-install-soft << "EOF"
echo "Installing the CUDA drivers - lib32"
cp -v libcuda.so* \
libnvidia-encode* \
libnvidia-ptx* \
libnvidia-nvvm* \
libnvcuvid.so* \
/usr/lib32 &&
EOF
NGX Drivers
NGX implements DLSS. Add to the script if you want DLSS.
cat >> nvidia-install-soft << "EOF"
echo "Installing the NGX drivers"
mkdir -pv /usr/lib/nvidia/wine &&
cp -v libnvidia-ngx.so* \
/usr/lib &&
cp -v *nvngx*.dll \
/usr/lib/nvidia/wine &&
EOF
NVIDIA-Settings
Add to the script if you want nvidia-settings which can let
you change settings like framerate in the Xorg server.
cat >> nvidia-install-soft << "EOF"
echo "Installing NVIDIA-Settings"
cp -v libnvidia-gtk* /usr/lib &&
install -vm755 nvidia-settings /usr/bin &&
cp -v nvidia-settings.desktop \
/usr/share/applications &&
cp -v nvidia-settings.png \
/usr/share/pixmaps &&
EOF
NVIDIA-XConfig
Add to the script if you want nvidia-xconfig which can
generate X11 configuration files.
cat >> nvidia-install-soft << "EOF"
echo "Installing NVIDIA-XConfig"
install -vm755 nvidia-xconfig /usr/bin &&
EOF
NVIDIA-SMI
Add to the script if you want nvidia-smi which grabs
information about GPU loads, temperatures, etc. and display it on
the command line.
cat >> nvidia-install-soft << "EOF"
echo "Installing NVIDIA-SMI"
install -vm755 nvidia-smi /usr/bin &&
EOF
Installing the Install Script
Now that you have a custom install script made, it's time to
install it to the system so it can be ran whenever you update the
driver. Do so now as the root
user:
cat >> nvidia-install-soft << "EOF" &&
echo "Installation of NVIDIA driver software complete!"
EOF
install -vm755 nvidia-install-soft /usr/sbin
Configuring NVIDIA
Config Files
/usr/lib/modprobe.d/nvfb.conf
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/nvfb.conf
to
blacklist Nouveau and NVIDIAFB:
mkdir -pv /usr/lib/modprobe.d &&
cat > /usr/lib/modprobe.d/nvfb.conf << "EOF"
# Begin /usr/lib/modprobe.d/nvfb.conf
blacklist nouveau
blacklist nvidiafb
# End /usr/lib/modprobe.d/nvfb.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
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.16. 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.1 to get these libraries and a real
pkg-config file. Note that those
libraries will not be used when this driver is in use.