For the complete documentation index, see llms.txt. This page is also available as Markdown.

9.4 NVIDIA Graphics Drivers

NVIDIA Graphics Driver Overview

For desktop computers, if the CPU is an Intel processor with a model number ending in F (such as i5-9400F) or KF (such as i5-12600KF), then that model has no integrated graphics, and there is no need to handle integrated graphics-related configuration.

If you already have a discrete graphics card and the video output interface (DP or HDMI) is directly connected to the discrete graphics card, you typically do not need to configure the integrated graphics; just handle the discrete graphics driver.

Laptops without GPU passthrough capability must first install and configure the Intel integrated graphics driver (the relevant DRM module) as described in other chapters, and then follow the instructions below to complete the NVIDIA discrete graphics driver configuration.

Joining the video Group

Add the specified user to the video group to access graphics card devices:

# pw groupmod video -m actual_username

Installing the Graphics Driver

Install using pkg:

# pkg install nvidia-drm-kmod nvidia-settings

Or install using Ports:

# cd /usr/ports/graphics/nvidia-drm-kmod/ && make install clean
# cd /usr/ports/x11/nvidia-settings/ && make install clean

List installed NVIDIA-related software:

# pkg info -q | grep -i nvidia

Configuring the NVIDIA Graphics Driver

Execute the following commands to configure the NVIDIA kernel modules:

Warning

X11 users should not attempt to load the nvidia-drm.ko kernel module, as this may cause the system to crash. Wayland users should load it as needed.

Generating an X11 Configuration File

Note that if the system displays normally, there is no need to perform the steps in this section. Before executing Xorg -configure, you must ensure that no X server is currently running; otherwise, the command will fail.

Warning

Do not attempt to install and use the Port x11/nvidia-xconfig. This tool is currently not applicable and may cause the system to become unresponsive.

Hardware Acceleration and Decoders

Install the VDPAU driver and related libraries to support video hardware acceleration.

  • Install using pkg:

  • Or install using Ports:

After restarting, the NVIDIA driver will be properly enabled.

Viewing NVIDIA Driver Status

List all NVIDIA GPUs and their detailed information:

Example output of the nvidia-smi command:

  • View KDE system information:

KDE System Information
  • Open a movie using mpv, and you can observe the video memory usage increase significantly (from 3 MB to hundreds of megabytes); you can also use SMPlayer to watch.

mpv Video Memory Usage

Troubleshooting

nvidia-smi Command Reports "mismatch" Error

nvidia-smi error

When executing the nvidia-smi command, an error message "API mismatch" appears: this error indicates an API mismatch, usually caused by version compatibility issues. Possible causes include: version mismatch among NVIDIA driver components themselves, version mismatch between the NVIDIA driver and other NVIDIA software packages, or version mismatch between the NVIDIA driver and the current FreeBSD base system version.

It is recommended to first uninstall all NVIDIA software packages, then update the FreeBSD base system to the latest version, and then reinstall the driver.

If a version mismatch is reported, you need to first uninstall all installed NVIDIA-related packages, then follow the configuration in this section:

First list the installed NVIDIA-related packages, then delete them one by one:

How to Prevent Driver Updates

Lock each relevant package from the output of pkg info -q | grep -i nvidia using the pkg lock command.

For example:

However, running freebsd-update or patching/updating the system via PkgBase may also affect driver compatibility, so you need to weigh security needs against usability based on actual circumstances.

References

Exercises

  1. Test on a laptop with a directly connected GPU and submit a PR.

  2. Test NVIDIA CUDA invocation under the Linux compatibility layer.

  3. The official NVIDIA driver is distributed in binary closed-source form, while the FreeBSD kernel uses the BSD license. Analyze the compatibility controversy between closed-source kernel modules and the BSD license, and discuss whether the nouveau open-source driver can replace the closed-source solution on FreeBSD.

Last updated