* tools/docs: NixOS portability for first-open runner, bind_dev_nodes, pahole, and live-swap udev freeze * docs: note udev queue restart on failed or aborted live swaps * docs: drain in-flight udev workers with udevadm settle before freezing queue
19 KiB
Installation Guide (nvdriver / nvidia_rs.ko)
This step-by-step guide walks through building, installing, verifying, and (if needed) uninstalling nvdriver on the most common Linux distributions.
Before you start:
nvdriveris a Linux kernel driver replacement. You still need the standard NVIDIA userspace libraries (libcuda.so,nvidia-smi, etc. — 580.178.04 is the primary verified baseline) installed from your distribution. Check PARITY_AND_UNLOCKS.md to confirm your GPU's current support status before installing on a primary desktop machine.
Step 1 — Install Build Prerequisites (Choose Your Distro)
Ubuntu / Debian / Pop!_OS / Linux Mint
sudo apt update
sudo apt install -y \
build-essential git curl python3 binutils kmod zstd mokutil \
linux-headers-"$(uname -r)"
(If your kernel was built with Clang/LLVM, also install clang lld llvm.)
Arch Linux / CachyOS / EndeavourOS / Manjaro
sudo pacman -Syu --needed \
base-devel git curl python binutils kmod zstd mokutil \
linux-headers
(Replace linux-headers with the headers package matching your running kernel — for example linux-cachyos-headers, linux-zen-headers, or linux-lts-headers.)
Fedora / Nobara / RHEL-family
sudo dnf install -y \
gcc make git curl python3 binutils kmod zstd mokutil openssl \
kernel-devel-"$(uname -r)" kernel-headers
NixOS
NixOS does not populate /lib/modules/$(uname -r)/build or writable /lib/modules / /etc/modprobe.d paths like conventional FHS distributions. Enter a build shell that includes the matching kernel development tree (replace linuxPackages with your configured boot.kernelPackages attribute, e.g. linuxPackages_latest):
nix-shell -p gnumake gcc binutils kmod zstd pahole python3 git curl rustup linuxPackages.kernel.dev
(pahole is required by gen-btf.sh on kernels built with CONFIG_DEBUG_INFO_BTF=y, which is enabled by default in NixOS linuxPackages.)
Continue through Step 2 to clone the repository and install the Rust toolchain, then follow the NixOS build & install instructions in Step 4 instead of ./install.sh.
Step 2 — Install Rust (rustup)
nvdriver uses a pinned Rust toolchain specified in rust-toolchain.toml (currently 1.100.0 with the bare-metal x86_64-unknown-none target; aarch64-unknown-none for ARM64). Installing via rustup downloads the exact version automatically when you enter the repository:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
Clone the repository and verify Rust resolves the pinned toolchain:
git clone https://github.com/nvdriver/nvdriver.git
cd nvdriver
rustc --version
rustup target list --installed
You should see x86_64-unknown-none listed on x86_64 hosts (if not, run rustup target add x86_64-unknown-none). On ARM64 (aarch64) hosts, install the bare-metal ARM64 target as well:
rustup target add aarch64-unknown-none
Step 3 — Check Secure Boot (If Enabled)
Make sure mokutil is installed (Step 1), then check whether UEFI Secure Boot is turned on:
mokutil --sb-state
Important: Require a working
mokutil --sb-statebefore running./install.sh. Ifmokutilis missing or fails, stop and installmokutilfirst —./install.shrelies onmokutilto detect Secure Boot and treats a failed check as Secure Boot disabled (skipping signing, so the kernel will reject the unsigned modules).
-
If Secure Boot is disabled: skip to Step 4.
-
If Secure Boot is enabled: Linux refuses to load unsigned kernel modules.
./install.shautomatically signsnvidia_rs.kousing your Machine Owner Key (MOK) at/var/lib/shim-signed/mok/MOK.{priv,der}(or customMOK_PRIV/MOK_DERpaths). If you do not have an enrolled MOK yet:- Ubuntu / Debian:
sudo update-secureboot-policy --new-key sudo mokutil --import /var/lib/shim-signed/mok/MOK.der - Fedora / RHEL / Arch / other distros (portable OpenSSL key):
Keep the private key protected under
/root/mok, and store the public.dercertificate in a user-readable directory (such as/etc/nvdriver) so./install.sh's non-rootmokutil --test-keyenrollment check can read it:Then pass those key paths when installing in Step 4:sudo install -d -m 700 /root/mok sudo install -d -m 755 /etc/nvdriver sudo openssl req -new -x509 -newkey rsa:2048 \ -keyout /root/mok/MOK.priv -outform DER -out /etc/nvdriver/MOK.der \ -nodes -days 36500 -subj "/CN=nvdriver MOK/" sudo chmod 600 /root/mok/MOK.priv sudo chmod 644 /etc/nvdriver/MOK.der sudo mokutil --import /etc/nvdriver/MOK.derMOK_PRIV=/root/mok/MOK.priv MOK_DER=/etc/nvdriver/MOK.der ./install.sh - NixOS: sign modules through your NixOS Secure Boot setup (for example Lanzaboote /
sbctl) or configure kernel module signing in your NixOS kernel build.
Reboot, choose Enroll MOK in the blue MokManager screen, and then continue to Step 4.
- Ubuntu / Debian:
Step 4 — Build & Install
Option A: One-command install (recommended)
./install.sh
What ./install.sh does automatically:
- Builds
nvidia_rs.ko(plusnvidia_rs_drm.ko,nvidia_rs_modeset.ko,nvidia_rs_peermem.ko, and the optional UVM/modeset compatibility bridges) and runs the static kernel-hygiene audit (tools/check_kernel_module.py). - Signs the modules if Secure Boot is enabled.
- Extracts pre-GSP firmware packs (
gv100.fw,gp100.fw,gp10x.fw,gm20x.fw) from your installed 580.178.04nv-kernel.o_binary(checking both/usr/src/nvidia-srv-580.178.04/and/usr/src/nvidia-580.178.04/) and copies GSP firmware blobs (gsp_*.bin) to/lib/firmware/nvidia/. - Installs the kernel modules into
/lib/modules/$(uname -r)/updates/nvdriver, writes/etc/modprobe.d/nvdriver.conf(blacklistingnouveauand stocknvidia*withinstall nvidia /bin/false), configures udev rules +nvdriver-devnodes.service(Docker/Podman CDI-compatible bind mounts), and loadsnvidia_rs.
Common ./install.sh options
| Environment Variable | Example | When to use |
|---|---|---|
BUILD_BRIDGES=0 |
BUILD_BRIDGES=0 ./install.sh |
Skip building the stock nvidia-uvm.ko / nvidia-modeset.ko bridge modules (use nvidia_rs.ko's built-in UVM instead — useful if stock kernel modules aren't installed or have a different ABI). |
SKIP_VOLTA_FOREVER=1 |
SKIP_VOLTA_FOREVER=1 ./install.sh |
Skip automatic volta-forever installation on Volta (V100) GPUs. |
MODPROBE_ARGS=... |
MODPROBE_ARGS="pci_target=* runtime_engines=1 v100_hbm_ndiv=0" ./install.sh |
Customize the immediate modprobe nvidia_rs load only (does not persist across reboot). To persist options such as v100_hbm_ndiv=0, edit the options nvidia_rs ... line in /etc/modprobe.d/nvdriver.conf and rebuild your initramfs (Step 5). |
LLVM=1 |
LLVM=1 make modules |
Required if your distro kernel (such as some Arch/CachyOS kernels) was built with Clang/LLVM. |
Option B: Build-only / Safe Offline Verification (Does Not Touch Your Running GPU)
If you want to verify the build first without loading anything on your host:
cargo test --workspace --lib
make modules
(Use --lib on a fresh clone — some integration tests under src/nvidia/tests/ read untracked local 580.178.04 analysis files.)
Option C: NixOS Build & Persistent Configuration
After cloning the repository and installing Rust in Step 2 (inside the nix-shell from Step 1), resolve both the kernel dev tree (KDEV) and its module version (KVER) directly from your system's configured config.boot.kernelPackages.kernel (so the build never mismatches a flake input or a newly configured kernel vs uname -r):
# Flake-based NixOS (adjust flake path/host if your config lives outside /etc/nixos):
HOST="$(hostname)"
KDEV="$(nix build --no-link --print-out-paths "/etc/nixos#nixosConfigurations.${HOST}.config.boot.kernelPackages.kernel.dev")"
KVER="$(nix eval --raw "/etc/nixos#nixosConfigurations.${HOST}.config.boot.kernelPackages.kernel.modDirVersion")"
KERNEL_SOURCES="$KDEV/lib/modules/$KVER/build" make modules
# Channel / non-flake configuration.nix:
# KDEV="$(nix-build '<nixpkgs/nixos>' -A config.boot.kernelPackages.kernel.dev --no-out-link)"
# KVER="$(nix-instantiate --eval --raw '<nixpkgs/nixos>' -A config.boot.kernelPackages.kernel.modDirVersion)"
# KERNEL_SOURCES="$KDEV/lib/modules/$KVER/build" make modules
For quick non-persistent testing, load kernel-open/nvidia_rs.ko interactively with sudo insmod — make sure KVER matches your currently running kernel (uname -r), or reboot into the configured kernel first before loading the module.
Because ./install.sh assumes writable FHS paths, persist the modules on NixOS by packaging them into a derivation and adding it to boot.extraModulePackages and boot.kernelModules (required because nvidia_rs omits a PCI modalias table). Because Nix builds run in a network-isolated sandbox (so rustup cannot download toolchains at build time), add oxalica/rust-overlay to nixpkgs.overlays (e.g. via your flake's rust-overlay input) and supply the pinned Rust toolchain from rust-toolchain.toml (1.100.0 with x86_64-unknown-none, or aarch64-unknown-none on ARM64) in nativeBuildInputs.
For pre-GSP GPUs (Maxwell / Pascal / Volta), extract the firmware packs (gm20x.fw, gp100.fw, gp10x.fw, gv100.fw) from the matching NVIDIA 580.178.04 nv-kernel.o_binary (which passes the script's built-in SHA-256 check). Because NixOS does not populate /usr/src/nvidia-580.178.04/, extract the official 580.178.04 .run installer (or point at your local extracted 580.178.04 tree) and pass --rm-object:
sh NVIDIA-Linux-x86_64-580.178.04.run --extract-only
python3 tools/extract_gv100_firmware.py --family all \
--rm-object ./NVIDIA-Linux-x86_64-580.178.04/kernel/nvidia/nv-kernel.o_binary
# Produces target/firmware/nvidia-rs/580.178.04/*.fw
Then expose the kernel module (and, optionally for pre-GSP GPUs only, the versioned firmware directory) in your NixOS module (configuration.nix):
# In your NixOS module (pass `rust-overlay` and `nvdriver-src` via `specialArgs` / flake inputs;
# pass `nvdriver-fw` ONLY on pre-GSP Maxwell/Pascal/Volta GPUs after extracting firmware above,
# or omit it on GSP-RM Turing+ GPUs):
args@{ config, pkgs, lib, rust-overlay, nvdriver-src, ... }:
let
kernel = config.boot.kernelPackages.kernel;
# Read optional `nvdriver-fw` from `args` (`specialArgs`) / `_module.args` rather than a
# formal `? null` parameter, because NixOS's `applyModuleArgs` treats declared formal
# arguments as required.
nvdriverFw = args.nvdriver-fw or config._module.args.nvdriver-fw or null;
rustTarget = if pkgs.stdenv.hostPlatform.isAarch64 then "aarch64-unknown-none" else "x86_64-unknown-none";
rustToolchain = pkgs.rust-bin.stable."1.100.0".minimal.override {
targets = [ rustTarget ];
};
nvdriver = pkgs.stdenv.mkDerivation {
pname = "nvdriver";
version = "0.1.0";
src = nvdriver-src; # flake input (or /path/to/nvdriver for non-flake / --impure rebuilds)
nativeBuildInputs = kernel.moduleBuildDependencies ++ [ pkgs.python3 rustToolchain ];
buildPhase = ''
make modules KERNEL_SOURCES=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build
'';
installPhase = ''
mkdir -p $out/lib/modules/${kernel.modDirVersion}/extra
cp kernel-open/nvidia_rs*.ko $out/lib/modules/${kernel.modDirVersion}/extra/
'';
};
# Pre-GSP GPUs (Maxwell/Pascal/Volta) only; preserves nvidia-rs/580.178.04/*.fw.
# Lazy evaluation skips this derivation when `nvdriverFw` is null (GSP-RM hosts).
nvdriverFirmware = pkgs.runCommand "nvdriver-firmware" {} ''
mkdir -p $out/lib/firmware/nvidia-rs
cp -r ${nvdriverFw}/. $out/lib/firmware/nvidia-rs/
'';
in {
nixpkgs.overlays = [ rust-overlay.overlays.default ];
boot.extraModulePackages = [ nvdriver ];
boot.kernelModules = [ "nvidia_rs" ];
hardware.firmware = lib.optional (nvdriverFw != null) nvdriverFirmware;
boot.blacklistedKernelModules = [ "nouveau" "nvidia" "nvidia_uvm" "nvidia_modeset" "nvidia_drm" ];
}
- Flake-based NixOS (pure evaluation): declare
nvdriver-src(flake = false;) — and, for pre-GSP GPUs,nvdriver-fw(url = "path:/path/to/nvdriver/target/firmware/nvidia-rs"; flake = false;) — as flake inputs and pass them viaspecialArgs. Alternatively, if you substitute absolute host paths directly insrc/nvdriver-fw, pass--impurewhen rebuilding (sudo nixos-rebuild switch --impure). - Channel / non-flake
/etc/nixos/configuration.nix: absolute host paths (/path/to/nvdriverand/path/to/nvdriver/target/firmware/nvidia-rs) evaluate directly without--impure(replacerust-overlay.overlays.defaultwithimport /path/to/rust-overlayif not using a flake).
Step 5 — Rebuild Initramfs, Reboot & Verify
If your distribution embeds nvidia.ko (or nouveau) in the initramfs, rebuild the initramfs before rebooting so /etc/modprobe.d/nvdriver.conf takes effect during early boot and stock nvidia cannot claim the GPU first:
- Ubuntu / Debian / Pop!_OS / Linux Mint:
sudo update-initramfs -u - Fedora / Nobara / RHEL-family (see also
contrib/rhel-5.14-boot/for RHEL-specific notes):sudo dracut --force --regenerate-all - Arch Linux / CachyOS / EndeavourOS / Manjaro:
sudo mkinitcpio -P # (Or `sudo dracut-rebuild` / `sudo booster build` if your install uses dracut or booster.)
If stock nvidia.ko previously initialized your GPU during the current boot, reboot once after rebuilding the initramfs so nvidia_rs.ko claims the GPU cleanly from cold boot (stock nvidia.ko leaves some GPUs in a state that prevents clean handoff without a reboot).
After reboot, verify the driver is loaded and bound:
lsmod | grep nvidia_rs
dmesg | grep -i nvidia_rs | tail -n 30
# When stock nvidia.ko is unloaded, run NVML/CUDA clients via the namespace launcher
# (see Troubleshooting below; find your BDF with `lspci -D | grep -i nvidia`):
sudo python3 tools/rmapi_namespace_launcher.py \
--gpu-node 0=/dev/nvidia-rs-rmapi-gpu0 \
--bdf 0=0000:01:00.0 -- nvidia-smi
Check native Linux hwmon telemetry (works even without nvidia-smi):
for h in /sys/class/hwmon/hwmon*; do
[ "$(cat "$h/name" 2>/dev/null)" = "nvdriver" ] && \
echo "$h: temp=$(($(cat "$h/temp1_input")/1000))C gpc=$(cat "$h/gpc_clock_mhz")MHz mem=$(cat "$h/mem_clock_mhz")MHz"
done
Troubleshooting
Failed to initialize NVML: GPU access blocked by the operating system
Stock libnvidia-ml.so and libcuda.so check /sys/module/nvidia/initstate == "live" before opening /dev/nvidia0. When nvidia_rs.ko is loaded without stock nvidia.ko, /sys/module/nvidia does not exist unless presented via a mount namespace:
- Make sure
/etc/modprobe.d/nvdriver.confcontains:(A plaininstall nvidia /bin/false install nvidia_uvm /bin/falseblacklist nvidiais bypassed by setuidnvidia-modprobe.) - Run your workload through
tools/rmapi_namespace_launcher.py, passing your GPU node and PCI address (find your BDF withlspci -D | grep -i nvidia):sudo python3 tools/rmapi_namespace_launcher.py \ --gpu-node 0=/dev/nvidia-rs-rmapi-gpu0 \ --bdf 0=0000:01:00.0 -- nvidia-smi
NVIDIA CDI refresh requires PyYAML
For NVIDIA Container Toolkit installations, nvdriver's CDI refresh hook adds a
read-only /dev/char mount so NVML can resolve nvdriver device nodes inside
containers. Install the PyYAML package for your system Python
(python3-yaml on Debian/Ubuntu, python3-pyyaml on Fedora/RHEL,
or python-yaml on Arch), then regenerate the spec:
sudo systemctl restart nvidia-cdi-refresh.service
Bridge build fails with modprobe: FATAL: could not get modversions ... No data available
Some custom kernels (such as CachyOS or custom Gentoo kernels) disable CONFIG_MODVERSIONS. Update to the latest master (or pass BUILD_BRIDGES=0 ./install.sh to use nvidia_rs.ko's built-in UVM).
Firmware file not found (gv100.fw / gp10x.fw / gsp_*.bin)
- Pre-GSP cards (Maxwell / Pascal / Volta): Extract the signed firmware packs from your installed 580.178.04 driver package:
sudo python3 tools/extract_gv100_firmware.py --family all sudo cp -r target/firmware/nvidia-rs /lib/firmware/ - GSP-RM cards (Turing / Ampere / Ada / Hopper / Blackwell): Ensure
/lib/firmware/nvidia/<version>/gsp_tu10x.binorgsp_ga10x.binis installed (provided by your distro'slinux-firmwareor NVIDIA driver package).
GP104 recovery after a Devinit DMA timeout
If a Tesla P4 or GTX 1070 logs Devinit DMA retained, close its clients and unbind it from nvidia_rs. The driver keeps the DMA buffers and pins the module, so an unload attempt reports that the module is in use. Cleanup checks for disabled bus mastering and drained PCIe transactions while the function is unbound.
Binding the function to nvidia_rs retries the drain during PCI probe. The probe returns EAGAIN while the old owner finishes cleanup. Once the kernel logs Devinit DMA cleanup complete; BAR0 released, bind again. If the device remains connected and the drain keeps failing, arrange a maintenance power cycle. The driver can also release the buffers when PCI reports a physical disconnect.
Testing Safely Without Risking Your Host Desktop (VFIO VM)
If you have an iGPU or second GPU and IOMMU enabled, test nvdriver inside a disposable QEMU/KVM VFIO VM instead of bare metal:
sudo python3 tools/vm/run_vfio_guest.py --bdf 0000:01:00.0 --driver rust
Rolling Back / Uninstalling
To remove nvdriver and return to your distribution's stock nvidia or nouveau driver:
sudo systemctl disable --now nvdriver-devnodes.service 2>/dev/null || true
sudo rm -f \
/etc/modprobe.d/nvdriver.conf \
/etc/modules-load.d/nvdriver.conf \
/etc/udev/rules.d/70-nvdriver.rules \
/etc/systemd/system/nvdriver-devnodes.service \
/etc/systemd/system/nvidia-cdi-refresh.service.d/10-nvdriver-dev-char.conf \
/usr/local/sbin/nvdriver-bind-dev-nodes \
/usr/local/sbin/nvdriver-cdi-patch
sudo rm -rf "/lib/modules/$(uname -r)/updates/nvdriver"
sudo depmod -a
sudo systemctl daemon-reload
# Rebuild your distro's initramfs (update-initramfs -u / dracut --force --regenerate-all / mkinitcpio -P)
sudo reboot
NixOS Rollback
If you installed nvdriver via configuration.nix:
- Remove
nvdriverfromboot.extraModulePackages,"nvidia_rs"fromboot.kernelModules, andnvdriverFirmwarefromhardware.firmware(if added). - Remove
"nouveau","nvidia","nvidia_uvm","nvidia_modeset", and"nvidia_drm"fromboot.blacklistedKernelModules. - Rebuild and reboot:
sudo nixos-rebuild boot sudo reboot