// HACKER NEWS — CYBERSECURITY
Virtio-nvgpu: Near-native Nvidia GPU access inside a KVM guest
Near-native NVIDIA GPU access inside a KVM guest. A guest renders within 2% of
the machine it is running on, and costs the same CPU.
virtio-nvgpu forwards NVIDIA kernel driver ioctls between a Linux guest and
the host at the driver ABI level, bypassing API-level translation entirely.
The guest runs NVIDIA's own user-mode drivers, unmodified — the same libraries,
the same Vulkan and NVENC, talking to the same card.
The target is headless streaming: a compositor inside the VM renders,
composites and encodes frames on the GPU, then sends compressed video out. The
VM has no monitor, and the host keeps the card.
It works, and it has been measured. A Wayland client presents inside a
guest, the capture layer encodes on the game's own device, and the H.264 comes
out the other side — 618 frames that ffmpeg decodes without an error.
Measured on an RTX 3060 (driver 595.99.02), guest against the same host, bare
metal, with an identical headless Vulkan load:
Above about 2 ms a frame — which is every frame a game draws — a guest is
within 2% of bare metal. Below that, the cost of waiting for the GPU starts to
show against a frame that barely exists.
CPU is the other half of it, because a shared GPU is only worth sharing if the
guests are cheap. Unpaced at ~100 fps for 12 s, one guest:
A guest costs what the host costs. Nothing is spent on forwarding in a
render loop, because nothing is forwarded: NVIDIA's user-mode driver submits
through memory it has mapped, and that memory is the host's. Over 813,691
frames the backend served 13,792 messages — one crossing per 59 frames, nearly
all of it device setup.
Full method, raw runs and the things these numbers do not support:
BENCHMARKS.md.
Four guests on one RTX 3060, the same load in each: 25.84, 26.49, 25.57, 25.79
fps — 103.7 together, against 102.9 for a single guest — with p50 frame times
of 39.165, 39.164, 39.168 and 39.165 ms. The total does not move as guests are
added, and the split is even to four decimal places.