A project for an open kernel driver on FreeBSD 16-CURRENT that serves the Nvidia driver for both CUDA, with NVIDIA's official userspace...

Hello.

I'm happy to discuss this project with you.

Goal: an open kernel driver on FreeBSD 16-CURRENT that serves the RTX 2080 Ti (but with some little adaptation it works for every Nvidia GPU) for both CUDA, with NVIDIA's official userspace, and open graphics with Mesa NVK and Zink. A single driver on the GPU.


Astra's proposal, right in its core idea: start from NVIDIA OpenRM (open-gpu-kernel-modules) instead of nouveau, because nouveau gives no CUDA while OpenRM was built for the CUDA userspace. The precedent is X547/nvidia-haiku (OpenRM, NVK and Zink on Haiku), and the missing piece on FreeBSD is UVM.


Corrections:

  1. OpenRM on FreeBSD already exists: cloudbsdorg/nvidia-gb10-freebsd combines NVIDIA's FreeBSD layer with the open 580.178.04 core, on amd64 and arm64. cloudbsdorg/uvm-bsd is a native BSD-2 UVM, and with it Linux CUDA runs under the Linuxulator, llama.cpp included. Both tested on a single machine. Porting the core means rebuilding and linking it, so Astra's difficulty table is overstated.
  2. The real gap is Turing: nvidia.ko targets Ampere and later, and with Turing it attaches without anyone ever having tested it. uvm-bsd supports only Blackwell GB20x, so Turing has to be added. amd64 has never been tested either.
  3. NVK doesn't go through a DRM adapter: it uses a backend that talks directly to the NVIDIA driver. X547's MIT backend can be reused.
  4. nvdriver must be excluded for provenance: its code says it was decompiled from NVIDIA's blob; it's not just a matter of age.
  5. The Linuxulator needs changes: libcuda needs base-kernel changes, namely the /proc files it reads and Linux abstract sockets.
  6. No UVM on the proprietary driver: with the rebuilt open core that path is no longer needed.
  7. Licences: core MIT, uvm-bsd BSD-2, NVK MIT. The FreeBSD layer is under NVIDIA's licence, while GSP firmware and CUDA libraries stay proprietary.
  8. Quality and minor details: the CloudBSD projects are written by AI agents and need verifying. Gdev's last commit is from 2017, not 2012.

Revised plan:

  1. Build the driver on amd64, with the 2080 Ti dedicated to development and the desktop on the UHD 630.
  2. Apply the kernel changes for the Linuxulator.
  3. Add Turing to uvm-bsd, then test vectorAdd, llama.cpp on CUDA and PyTorch.
  4. Get NVK working: compute only first, then on-screen presentation.
  5. Optional: rewrite the FreeBSD layer as open code.

With OpenRM and NVK, nouveau is no longer needed for Turing and later.


Maintenance: firmware, core, FreeBSD layer and NVIDIA libraries must share the same version. Pin the 580 branch. Updates within the branch are cheap; branch jumps are costly.

These are the advantages of the OpenRM route: NVIDIA's open core, the FreeBSD layer, uvm-bsd, NVK and the NVIDIA libraries through the Linuxulator.


Compared with today's proprietary FreeBSD driver

  1. Real UVM instead of dummy-uvm: a native /dev/nvidia-uvm, with cuInit, contexts and basic managed memory. It doesn't break every time the UVM interface changes, as it did with the 550 series. For Turing, support has to be added to uvm-bsd first.
  2. No blob in the kernel: the RM core is built from MIT source with the base system's tools. You can debug inside RM with kgdb and dtrace, and fix bugs yourself.
  3. Modifiable: CloudBSD has already added GPU access control per jail and per user, plus resource accounting (racct). With the blob that's impossible.
  4. arm64: the official FreeBSD driver exists only for x86-64, with a prebuilt nv-kernel.o. The open core also builds for aarch64. github
  5. A path to native CUDA without the Linuxulator: libnvrm with native libcuda/libcudart, still in progress but saxpy has already run on an RTX 5060 Ti.

Compared with a nouveau port

  1. Real CUDA: the official libcuda, cuBLAS, cuDNN, PyTorch and llama.cpp run, not a reimplementation.
  2. Same driver as Linux and Windows: same RM and same firmware for clocks, power, NVENC/NVDEC and NVIDIA's Vulkan.
  3. One kernel driver for graphics and compute: no two drivers fighting over the GPU.
  4. No chasing GSP calls: firmware and core arrive already in sync from NVIDIA.
  5. Far less code to write: the FreeBSD layer already exists. No drm_gpuvm to port and no CUDA to reinvent.
  6. Maintenance handled by NVIDIA: new GPUs and security fixes land in the core.
  7. Open graphics still possible: NVK with X547's RM backend, MIT, about 2,200 lines, already running on Haiku with the Turing firmware.

Project advantages

  1. You start from a working system: driver, UVM, monitor and display modesetting already exist.
  2. Your contribution is clear and bounded: amd64 and Turing, exactly the two things CloudBSD lists as untested, plus Turing support in uvm-bsd.
  3. Permissive licences, no GPL: core MIT, uvm-bsd BSD-2, NVK MIT. Only the FreeBSD layer is under NVIDIA's licence, and it can be rewritten on the Haiku model.
  4. SteamBSD stays as it is today: NVIDIA's Linux Vulkan runs through the Linuxulator on the same RM, with NVK as an extra option.
  5. You set the update pace: on a fixed branch, updates within the branch are cheap.

The trade-off is the one already covered: GSP firmware and CUDA libraries are proprietary, and firmware, core, FreeBSD layer and libraries all have to be updated together.

 
Back
Top