DEV Community

RobustTrueTry
RobustTrueTry

Posted on

P2P Between GPUs Is Blocked by Your Driver — Rust Fixes It

NVIDIA's proprietary kernel driver deliberately disables features your hardware supports. PCIe peer-to-peer (P2P) transfers between consumer GPUs are gated off, NVENC session counts are capped, and unprivileged profiling with ncu is blocked. If you run inference across multiple GPUs, you pay for that gating in transfer time and dev-loop friction every day.

By the end of this piece you'll know what the nvdriver clean-room module actually replaces, how to sanity-check compatibility before loading it, and which tradeoffs should stop you from putting it on a production node.

What a clean-room driver can legally change

nvdriver is a #![no_std] Rust kernel module (nvidia_rs.ko) built without copying any of NVIDIA's code. It speaks to the same GPU command interfaces, then exposes the ones the closed driver disables: resizable BAR1 by default, BAR1 P2P across GPUs, GPUDirect RDMA, unlimited NVENC sessions, and vGPU without GRID license timers.

The important claim is not performance. It's that unmodified NVIDIA userspace keeps working. libcuda.so, nvidia-smi, PyTorch, NCCL, and llama.cpp make ioctls into the kernel module; nvdriver implements those interfaces, including bridges to stock nvidia-uvm.ko and nvidia-modeset.ko. You don't rebuild your stack, you swap one kernel module.

Check your userspace contract first

The drop-in promise has a hard dependency: you must already have NVIDIA's userspace libraries installed, and their version has to match what the module implements. Before touching your kernel modules, verify what you're running:

nvidia-smi --query-gpu=driver_version,name,persistence_mode --format=csv
ls -l /usr/lib/x86_64-linux-gnu/libcuda.so* /usr/lib/x86_64-linux-gnu/libnvidia-ml.so*
Enter fullscreen mode Exit fullscreen mode

The first line tells you the driver release and GPU family. nvdriver's compatibility spans Maxwell through Blackwell in its documentation, with GSP-RM (GPU System Processor firmware) required for Turing and newer. Older Maxwell and Pascal cards work natively in-kernel instead.

If any of this mismatches what the project's docs declare, stop there. A mismatched kernel module and userspace pair fails at ioctl time with errors that look like broken CUDA, not broken drivers.

Where the real wins are

The features the closed driver gates are the ones that hurt multi-GPU and encode workloads:

  • P2P over BAR1: with the closed driver on consumer cards, tensors must hop through host memory. A torch.distributed all-reduce across four consumer GPUs takes a PCIe round-trip per step that P2P eliminates.
  • NVENC session caps: the closed driver limits concurrent encode sessions by product tier. Streaming or transcode pipelines hit NV_ENC_ERR_OUT_OF_MEMORY well before the hardware saturates.
  • Unprivileged profiling: ncu and nsys normally need root or a config change. Running your profiler under your own user shortens the dev loop noticeably.
  • hwmon telemetry: the module exposes standard /sys/class/hwmon nodes, so lm-sensors, btop, and Prometheus node_exporter read GPU clocks and temps with no vendor plugin.

That telemetry point is worth a config snippet, because it removes the NVML dependency from your monitoring entirely:

# node_exporter reads hwmon by default; just confirm the nodes exist
for g in /sys/class/hwmon/hwmon*; do
  [ -f "$g/name" ] && grep -q nvidia "$g/name" \
    && cat "$g/temp1_input" "$g/power1_average" 2>/dev/null
done
Enter fullscreen mode Exit fullscreen mode

Standard hwmon means one less proprietary path in your metrics pipeline.

The V100 claim, read carefully

The project reports unlocking Tesla V100 HBM2 clocks to the V100S factory spec, which raises memory bandwidth over stock. That number is specific to GV100 silicon and verified on 8-GPU SXM2 hardware per the repo.

Treat it as a narrow result, not a general one. Overclocking via a kernel module on hardware you don't own (a cloud instance, a shared lab box) is a support and warranty problem, not a benchmark problem. If you quote the bandwidth figure anywhere, quote the hardware it came from.

What to test before you trust it

A kernel module replacement deserves the same skepticism as a database replacement. The repo ships a validation script and a parity suite; run both before touching a node you care about:

sh tools/validate_all.sh   # build + unit + QEMU guest + kernel-hygiene gates
Enter fullscreen mode Exit fullscreen mode

Then run your own minimal parity check against the workload that matters to you. For CUDA correctness, a cheap canary beats a benchmark suite:

import torch

# determinism canary: same input must give bit-identical output
a = torch.randn(4096, 4096, device="cuda", dtype=torch.float32)
b = a @ a
print(b.flatten()[0].item(), b.flatten()[-1].item())
print(torch.cuda.mem_get_info())
Enter fullscreen mode Exit fullscreen mode

Run it under the stock driver, record the outputs, then unload the stock module, load nvdriver, and run it again. Identical values plus sane memory info is your baseline green light. Do the same for any NCCL job if you depend on multi-GPU collectives.

Failure modes the README won't show you

  • Secure Boot: an out-of-tree module must be signed or SecureBoot enforcement will refuse it silently at load time. Check mokutil --sb-state before debugging anything else.
  • Kernel updates: CONFIG_MODVERSIONS bridges pin you to specific symbol versions. A routine dnf upgrade that bumps the kernel can break the module until the project rebuilds — pin your kernel on shared nodes.
  • Feature flags are yours to own: unlocking ECC toggling or vGPU licensing means nobody upstream is validating those paths for you. Enable what your workload needs, not everything the README lists.
  • Support surface: NVIDIA will not reproduce bugs against this module. If you file a bug with libcuda.so while running it, expect a closed report.

The honest placement: a workstation or homelab where the P2P and NVENC unlocks pay off immediately, and a staging ring on identical hardware before any training cluster adoption.

Key takeaways

  • nvdriver swaps only the kernel module; your NVIDIA userspace, CUDA, and PyTorch builds stay untouched, which is what makes it testable.
  • Verify your userspace driver version and GPU generation against the project's compatibility matrix before loading anything.
  • The practical wins are gated features — BAR1 P2P on consumer GPUs, NVENC session caps, unprivileged profiling — not raw throughput.
  • Run the repo's validation script plus a small determinism canary of your own on identical hardware before trusting it.
  • Expect out-of-tree-module friction: Secure Boot signing, kernel-version pinning, and zero vendor support.

Source

nvdriver — clean-room Rust Linux kernel driver for NVIDIA GPUs — this article adds the compatibility checks, a validation workflow, and the operational tradeoffs the README leaves out.

Support this work

These write-ups are researched and published with no paywall, sponsor, or tracking. If one saved you an afternoon, a small tip keeps them coming.

USDT, USDC or USDD · TRC-20 (Tron)

TFTNsfyomKrnUutRjBTGVULp19ByW29KbY
Enter fullscreen mode Exit fullscreen mode

Top comments (0)