{"slug": "running-the-nvidia-driver-inside-baremetal-uefi-and-a-gpu-enabled-llm", "title": "Running the Nvidia driver inside baremetal UEFI (and a GPU enabled LLM)", "summary": "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.", "body_md": "This repository was created to answer a question of how much is a full deskopt operating system getting in the way of LLM TPS.\n\nGPUOS 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.\n\n- CPU: AMD Ryzen 9 9950X @ 5.76 GHz\n- GPU: NVIDIA GeForce RTX 4070\n- RAM: 32 GiB DDR5 @ 5200 MHz\n\n- OS: Ubuntu 26.04.1 LTS\n- Kernel: Linux 7.0.0-44-generic\n\nIn [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.\n\nThis benchmark with the adapted Llama harness is ran under:\n\n1. Linux Userspace (Noted further as \"Linux\")\n2. As an UEFI app under KVM with GPU passed through via VFIO (Noted further as \"VM\")\n3. As a baremetal UEFI application booted directly on the CPU (Noted further as \"UEFI\")\n\nMedian TPS across these enviromnets are as follows:\n\n| Linux | VM | UEFI | \n|---|---|---|\n| 163.5 | 163.6 | 164 | \n\nLinux 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.\n\n- gcc and binutils (ld, objcopy)\n- gnu-efi (Ubuntu/Debian: `apt install gnu-efi` )\n- NVIDIA CUDA toolkit, for `nvcc` (compiles the GPU kernels to cubin)\n- mtools (`mcopy` ) and dosfstools (`mkfs.vfat` )\n- git, and curl or wget\n- For the VM target: `qemu-system-x86_64` and OVMF (`ovmf` package)\n\nGPUOS statically links NVIDIA's open GPU kernel driver and loads a GGUF model at runtime. Neither lives in this repo. Fetch both with:\n\n```\n./setup.sh\n```\n\nThis clones `NVIDIA/open-gpu-kernel-modules` pinned to 620.73.04 into\n`../open-gpu-kernel-modules` (a sibling of this repo, which is where the Makefile\nexpects it), and downloads the Llama-3.2-1B-Instruct F16 GGUF into `models/`. It\nalso reports any missing build tools.\n\n```\nmake            # the UEFI application: build/BOOTX64.EFI and build/gpuos.img (EFI only)\nmake llm-img    # bootable image bundling the app, the weights and the GPU kernels\n```\n\n`make llm-img` produces `build/gpuos_llm.img`, a FAT32 image sized to the model.\nIt places the EFI app at `/EFI/BOOT/BOOTX64.EFI` and the GGUF plus `llama.cubin`\nat the filesystem root, which is where the app reads them from the boot volume at\nruntime. Use a different model with `make llm-img GGUF=/path/to/model.gguf`.\n\nBind the GPU (both functions) to `vfio-pci` first, then:\n\n```\ncp /usr/share/OVMF/OVMF_VARS_4M.fd build/OVMF_VARS.fd\nsudo qemu-system-x86_64 -machine q35,accel=kvm -cpu host,-x2apic -enable-kvm -m 8G -no-reboot \\\n  -drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \\\n  -drive if=pflash,format=raw,unit=1,file=build/OVMF_VARS.fd \\\n  -drive format=raw,file=build/gpuos_llm.img \\\n  -device vfio-pci,host=0000:01:00.0,multifunction=on \\\n  -device vfio-pci,host=0000:01:00.1 \\\n  -display none -serial null -serial file:serial.log\n```\n\nThe passed-through GPU drives its own attached monitor. To type at the\ninteractive prompt, pass a USB keyboard through too, for example:\n`-device qemu-xhci,id=xhci -device usb-host,bus=xhci.0,vendorid=0xVVVV,productid=0xPPPP`.\n\n```\nmake llm-img\nsudo dd if=build/gpuos_llm.img of=/dev/sdX bs=16M oflag=direct status=progress\n```\n\nReplace `/dev/sdX` with your USB device (this erases it), then boot it from the\nfirmware boot menu. Use a USB keyboard to interact.\n\nAt the `>` prompt, type a message and press Enter to chat. Type `[[benchmark]]`\nto run the prompt suite and print the median TPS. Type `/quit` to exit.", "url": "https://wpnews.pro/news/running-the-nvidia-driver-inside-baremetal-uefi-and-a-gpu-enabled-llm", "canonical_source": "https://github.com/bane9/GPUOS", "published_at": "2026-11-30 22:16:50+00:00", "updated_at": "2026-11-30 22:45:38.814936+00:00", "lang": "en", "topics": ["large-language-models", "ai-infrastructure", "ai-tools"], "entities": ["GPUOS", "NVIDIA", "Llama-3.2-1B", "AMD Ryzen 9 9950X", "NVIDIA GeForce RTX 4070", "Ubuntu", "QEMU", "bane9"], "also_reported_by": [], "takeaway": "Running Llama-3.2-1B on an RTX 4070 in bare-metal UEFI with NVIDIA's driver yielded a median 164 TPS versus 163.5 on Linux and 163.6 in a VFIO-passthrough VM, so the full desktop OS costs only about 0.5 TPS.", "recommendation": {"advice": "If you suspect OS overhead limits LLM throughput, benchmark the same model and GPU in a bare-metal or VM environment before optimizing; here the full Linux stack cost only about 0.5 TPS.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/running-the-nvidia-driver-inside-baremetal-uefi-and-a-gpu-enabled-llm", "markdown": "https://wpnews.pro/news/running-the-nvidia-driver-inside-baremetal-uefi-and-a-gpu-enabled-llm.md", "text": "https://wpnews.pro/news/running-the-nvidia-driver-inside-baremetal-uefi-and-a-gpu-enabled-llm.txt", "jsonld": "https://wpnews.pro/news/running-the-nvidia-driver-inside-baremetal-uefi-and-a-gpu-enabled-llm.jsonld"}}