NVIDIA GPU and CUDA.
From 15.2, FreeCORE adds a CUDA service. With it on, a Linux application or a jail can use the system’s NVIDIA GPU for compute. NVIDIA publishes no CUDA for FreeBSD®. What runs is FreeBSD’s native NVIDIA driver together with NVIDIA’s Linux CUDA userland under Linux binary compatibility, inside the container or jail. Everything is opt-in. A system that never enables the service is unchanged.
The feature is experimental. It was validated on one card, an RTX A2000, in a virtual machine with the GPU passed through. See Codeberg freecore/freecore#127 for what has been tried and to report another card.
Before You Begin
Section titled “Before You Begin”- An NVIDIA GPU of the Turing generation or newer. The shipped driver no longer supports Maxwell, Pascal or Volta cards.
- For applications, Linux binary compatibility (experimental) turned on under Applications Settings, as for any Linux image. See Installing and Managing Applications.
- The Linux CUDA userland of the shipped driver version comes with the
image as the
freecore-cuda-libspackage, about 330 MB. Nothing is put in/compat/linux. Containers and jails mount it.
Enable the CUDA Service
Section titled “Enable the CUDA Service”Go to Services and click the CUDA toggle to start the service. Select Start Automatically to have it on after a reboot. Enabling it loads the NVIDIA kernel module and the Linux compatibility modules and checks that the CUDA userland matches the loaded driver. The service has no settings of its own.
Screenshot to come: the Services screen with the CUDA row turned on, on 15.2-RELEASE with an NVIDIA GPU.
It refuses to enable on a system without an NVIDIA GPU on the PCI bus, and to stop while an application, container or jail is using the GPU. The message names the holder. Stop that application or jail first.
Applications
Section titled “Applications”A Linux image can take the GPU. In Import image…, choose Linux and select NVIDIA GPU (CUDA). The same option appears in the install and edit forms of a catalog entry whose image is a Linux one that declares GPU support. FreeBSD-native applications never see any of this.
Shown on a system without an NVIDIA GPU and with Linux binary compatibility off, so the form asks for both first.
An application with the option gets the GPU device nodes, the Linux NVIDIA driver libraries and a small preload library. It starts only while CUDA is running, and CUDA cannot be stopped while it runs. After a driver update, the application’s container is re-created on its next start. Its data is untouched. The installed list shows CUDA in the application’s GPU column.
In the application’s log, a CUDA program reports the GPU as it would on
Linux. Ollama, for example, logs library=CUDA.
The jail form has an NVIDIA GPU option (the nvidia property on the
command line). A jail with it gets the device nodes /dev/nvidiactl,
/dev/nvidia0 and so on through its own devfs rule set, so DHCP and the
other device settings keep working. The host must have the NVIDIA module
loaded, either by the CUDA service or by the native NVIDIA opt-in of 15.1.
Inside the jail, nvidia-smi and NVML come from the nvidia-driver-headless
package. Running CUDA programs in a jail additionally needs the Linux
userland from /usr/local/share/freecore/cuda/ mounted into the jail.
FreeCORE 15.2 does not do that for you.
Limits
Section titled “Limits”- Unified (managed) memory stays off. The FreeBSD driver provides no unified-memory device, and the preload library answers for it. Ordinary allocations and copies are unaffected.
- Stream-ordered allocation is not available either:
cudaMallocAsyncfails with “operation not supported”. PyTorch’s default allocator works; a program that selects the asynchronous one (PYTORCH_CUDA_ALLOC_CONF=backend:cudaMallocAsync) must keep the default. Allocators built on CUDA virtual memory management fail the same way, such as ComfyUI’s dynamic VRAM manager (“VBAR allocation failed”). - ComfyUI needs both turned off. Start it with
python main.py --disable-dynamic-vram --disable-cuda-malloc; with those two flags it runs on the GPU. - NVENC and other video acceleration are not available in FreeBSD-native jails. The FreeBSD driver ships no NVENC.
- Loading the NVIDIA module also loads the Linux compatibility modules, because the module is built with Linux ioctl compatibility. They are inert without Linux callers.
- A model server can hold much of the host’s free memory. Under sustained load,
Ollama’s model runner keeps growing into free memory and keeps it while the
model stays loaded; it is released when the model unloads, after 5 minutes
idle by default (
OLLAMA_KEEP_ALIVE). On a system with little spare memory this crowds out the ZFS cache and other applications, so plan memory for it or set a shorter keep-alive.
Previous
Reverse Proxy for ApplicationsNext
Plugins