GPU Passthrough
HYPR supports GPU passthrough for running GPU-accelerated workloads in VMs.Platform Support
| Platform | Method | Supported GPUs |
|---|---|---|
| Linux | VFIO | NVIDIA, AMD, Intel |
| macOS Apple Silicon | Metal via Venus | Integrated GPU |
| macOS Intel | Not supported | - |
Linux: VFIO Passthrough
On Linux, GPUs are passed through using VFIO (Virtual Function I/O), which provides direct hardware access to the VM.Prerequisites
-
IOMMU Enabled: Add to kernel command line:
- Intel:
intel_iommu=on - AMD:
amd_iommu=on
- Intel:
-
VFIO Modules: Ensure modules are loaded:
List Available GPUs
available- GPU can be used for passthroughvfio-ready- GPU is already bound to vfio-pci driverboot-vga- GPU is the primary display (cannot unbind without —force)
Run with GPU
- Validates the PCI address
- Checks IOMMU group isolation
- Binds the GPU to vfio-pci driver
- Passes the GPU to the VM
- Restores the original driver when VM stops
IOMMU Groups
All devices in an IOMMU group must be passed through together. HYPR validates this automatically. If validation fails:Boot VGA Protection
The boot VGA device (primary GPU driving the display) is protected by default. Unbinding it can hang the system. To override (use with caution):NVIDIA-Specific Notes
Driver Installation in VM: The VM needs NVIDIA drivers. Use an image with drivers pre-installed:macOS: Metal GPU
On Apple Silicon Macs, HYPR uses Metal GPU virtualization via the Venus Vulkan driver.How It Works
- libkrun creates a VM with virtio-gpu device
- Guest uses Venus driver (Vulkan over virtio-gpu)
- Host translates Vulkan to Metal
- GPU operations run on Apple GPU
Enable Metal GPU
List GPU
Performance
Metal passthrough achieves approximately 60-80% of native performance, depending on workload:- Compute (matrix ops): ~75-80%
- Graphics rendering: ~60-70%
- Memory bandwidth: ~70-75%
Supported Frameworks
Frameworks using Metal Compute or MPS work automatically:- TensorFlow with Metal plugin
- PyTorch with MPS backend
- MLX
- Core ML
Troubleshooting
Linux: GPU Not Available
IOMMU not enabled:sudo modprobe vfio-pci
GPU in use by host:
Stop display manager and unload GPU driver:
macOS: Metal Not Working
Check libkrun-efi version:Check GPU Usage in VM
NVIDIA (Linux):Compose with GPU
Define GPU access in compose files:Best Practices
- Use pre-built GPU images with drivers included
- Test GPU access before deploying workloads
- Monitor GPU memory to avoid OOM errors
- Restore drivers after VM shutdown (automatic)
- Isolate IOMMU groups for reliable passthrough