nestrilabs/virtio-nvgpu

A virtio device for sharing one NVIDIA GPU across several VMs, at bare-metal speed.

virtio-nvgpu – Share One NVIDIA GPU Across Multiple VMs

What it does

  • Provides a virtio device that lets several Linux virtual machines (VMs) use the same physical NVIDIA GPU without needing a vGPU license or PCI‑passthrough.
  • The host runs the official NVIDIA driver; the guest kernels load a small driver module that forwards the actual NVIDIA driver calls to the host. GPU commands are written directly into GPU memory, so the workload runs at near‑bare‑metal speed.

Why it matters

  • Traditional PCI‑passthrough gives a whole GPU to one VM, limiting consolidation.
  • NVIDIA’s vGPU solution is expensive and limited to datacenter‑class cards.
  • Existing API‑forwarding solutions (Venus, virgl) are slow and cannot expose NVENC or CUDA.
  • virtio‑nvgpu sidesteps these limits by sharing the driver itself, keeping performance high while allowing many guests.

Performance claims

  • On an RTX 3060, frame‑rendering latency is within 2 % of native bare‑metal performance for typical game frames (>2 ms).
  • CPU overhead is comparable to running on the host directly.
  • The authors demonstrated 12 VMs on a single card, each encoding 720p60 H.264 without dropped frames (limited by VRAM, host resources, and the 12‑session NVENC cap on GeForce cards).

Typical use cases

  • Cloud‑gaming or remote‑desktop services that need real‑time GPU acceleration.
  • CI pipelines or server‑less AI workloads that require a physical GPU but want isolation via VMs.
  • Any headless workload that benefits from CUDA, Vulkan, or NVENC on consumer‑grade NVIDIA GPUs.

Limitations & requirements

  • Only Linux hosts and guests are supported; the driver version must be 535.129.03 or newer.
  • Security is limited to the host driver – it is not a hardware isolation boundary. Untrusted tenants should use passthrough or NVIDIA’s official vGPU instead.
  • The project is early‑stage: tested on two GPU models, CUDA works but lacks extensive benchmarking.

How it is organized

  • driver/ – Guest‑side kernel module (GPL‑2.0).
  • device/ – VMM‑agnostic Rust implementation of the virtio device (Apache‑2.0).
  • protocol/ – Shared protocol definitions (BSD‑3/GPL‑2.0).

Further reading

  • Architecture details: ARCHITECTURE.md
  • Benchmark methodology and results: BENCHMARKS.md
  • Security considerations: SECURITY.md

Bottom line virtio‑nvgpu is a niche but practical solution for sharing a single consumer‑grade NVIDIA GPU across many Linux VMs while retaining near‑native performance, aimed at developers and operators who need GPU‑accelerated workloads in a multi‑tenant environment without the cost of NVIDIA’s vGPU licensing.

Related

  • Dispatch
  • Project
  • Project
  • Dispatch
  • Project