Running the Nvidia driver inside baremetal UEFI (and a GPU enabled LLM) A developer known as bane9 published GPUOS, an x86_64 UEFI application that runs NVIDIA's open GPU kernel driver (pinned to 620.73.04) directly on bare metal to run Llama-3.2-1B-Instruct, measuring a median 164 tokens per second versus 163.5 on Linux userspace and 163.6 in a KVM virtual machine with the GPU passed through via VFIO. The benchmark, run on an AMD Ryzen 9 9950X at 5.76 GHz with an NVIDIA GeForce RTX 4070 and 32 GiB DDR5-5200, averaged 11 prompts over 10 runs, and the author attributes the roughly 0.5 TPS gap to context-switching overhead in the Linux and VM environments. The repository ships setup and build scripts that fetch the driver and an F16 GGUF model, producing a bootable FAT32 image that loads the GGUF and llama.cubin from the boot volume at runtime. This repository was created to answer a question of how much is a full deskopt operating system getting in the way of LLM TPS. GPUOS is a x86 64 UEFI application that uses the real NVIDIA driver to talk to the GPU and a harness from running Llama-3.2-1B. - CPU: AMD Ryzen 9 9950X @ 5.76 GHz - GPU: NVIDIA GeForce RTX 4070 - RAM: 32 GiB DDR5 @ 5200 MHz - OS: Ubuntu 26.04.1 LTS - Kernel: Linux 7.0.0-44-generic In benchmark.cpp https://github.com/bane9/GPUOS/blob/master/llm/benchmark.c under PROMPTS there are a set of 11 different prompts Llama-3.2-1B is asked. Upon each answer min, max, mean and median TPS is calculated. After 10 runs those results are aggregated into one final result. This benchmark with the adapted Llama harness is ran under: 1. Linux Userspace Noted further as "Linux" 2. As an UEFI app under KVM with GPU passed through via VFIO Noted further as "VM" 3. As a baremetal UEFI application booted directly on the CPU Noted further as "UEFI" Median TPS across these enviromnets are as follows: | Linux | VM | UEFI | |---|---|---| | 163.5 | 163.6 | 164 | Linux and VM are effectively the same, while there's only a slight and consistent 0.5 TPS improvement in the baremetal environment. I believe the slight TPS regression in Linux/VM environment is purely an artifact of context switching. - gcc and binutils ld, objcopy - gnu-efi Ubuntu/Debian: apt install gnu-efi - NVIDIA CUDA toolkit, for nvcc compiles the GPU kernels to cubin - mtools mcopy and dosfstools mkfs.vfat - git, and curl or wget - For the VM target: qemu-system-x86 64 and OVMF ovmf package GPUOS statically links NVIDIA's open GPU kernel driver and loads a GGUF model at runtime. Neither lives in this repo. Fetch both with: ./setup.sh This clones NVIDIA/open-gpu-kernel-modules pinned to 620.73.04 into ../open-gpu-kernel-modules a sibling of this repo, which is where the Makefile expects it , and downloads the Llama-3.2-1B-Instruct F16 GGUF into models/ . It also reports any missing build tools. make the UEFI application: build/BOOTX64.EFI and build/gpuos.img EFI only make llm-img bootable image bundling the app, the weights and the GPU kernels make llm-img produces build/gpuos llm.img , a FAT32 image sized to the model. It places the EFI app at /EFI/BOOT/BOOTX64.EFI and the GGUF plus llama.cubin at the filesystem root, which is where the app reads them from the boot volume at runtime. Use a different model with make llm-img GGUF=/path/to/model.gguf . Bind the GPU both functions to vfio-pci first, then: cp /usr/share/OVMF/OVMF VARS 4M.fd build/OVMF VARS.fd sudo qemu-system-x86 64 -machine q35,accel=kvm -cpu host,-x2apic -enable-kvm -m 8G -no-reboot \ -drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/OVMF/OVMF CODE 4M.fd \ -drive if=pflash,format=raw,unit=1,file=build/OVMF VARS.fd \ -drive format=raw,file=build/gpuos llm.img \ -device vfio-pci,host=0000:01:00.0,multifunction=on \ -device vfio-pci,host=0000:01:00.1 \ -display none -serial null -serial file:serial.log The passed-through GPU drives its own attached monitor. To type at the interactive prompt, pass a USB keyboard through too, for example: -device qemu-xhci,id=xhci -device usb-host,bus=xhci.0,vendorid=0xVVVV,productid=0xPPPP . make llm-img sudo dd if=build/gpuos llm.img of=/dev/sdX bs=16M oflag=direct status=progress Replace /dev/sdX with your USB device this erases it , then boot it from the firmware boot menu. Use a USB keyboard to interact. At the prompt, type a message and press Enter to chat. Type benchmark to run the prompt suite and print the median TPS. Type /quit to exit.