Black Friday Deals Not Found Anywhere Else! Save up to 55% OFF Hosting, Domains, Pro Services, and more.
Vodien Black Friday Sale applies to new purchase on select products and plans until 4 December 2024. Cannot be used in conjunction with other discounts, offers, or promotions.
How to Enable GPU Passthrough on VPS for ML Workloads

How to Enable GPU Passthrough on VPS for ML Workloads

GPU passthrough dedicates an entire PCIe GPU to one virtual machine using hardware-assisted virtualisation. Compared to vGPU, it trades multi-user sharing for maximum throughput and performance isolation.

Near-native GPU performance on a virtual private server means faster model training and lower-latency inference without paying cloud-on-demand rates. GPU passthrough dedicates an entire physical GPU to one virtual machine, giving SMEs and dev teams the raw horsepower of bare metal with the flexibility of virtualisation. 

This blog delivers a concise, actionable checklist that takes you from hardware compatibility to a working TensorFlow setup.

Who Should Use GPU Passthrough?

Passthrough shines when a single VM needs maximum compute for deep-learning training, deterministic inference, or rapid experimentation. Teams running long training jobs, latency-sensitive services, or predictable workloads benefit most.

If many users must share a GPU, or if desktop-style sessions dominate, consider a virtual GPU (vGPU). For teams that prioritise zero-ops management, a fully managed cloud GPU may prove simpler.

Quick Decision Flow: Passthrough, vGPU or Managed Cloud?

Choosing the right approach depends on performance, concurrency, hosting cost and in-house skill.

  • Maximum throughput and deterministic performance? Opt for GPU passthrough.
  • Multiple users or desktop graphics? Evaluate vGPU and accept licensing costs
  • Minimal operational overhead? A managed cloud GPU or hosted GPU VPS could be easier.

If your team lacks time for hypervisor plumbing, shortlist VPS providers that offer ready-to-use GPU instances or a managed setup to accelerate deployment.

Preflight Checks: Hardware and Compatibility

Before touching the hypervisor, confirm that every hardware layer supports passthrough.

GPU Selection and Class

Enterprise GPUs (NVIDIA Tesla, Quadro, and data centre models) are designed for virtualisation, simplify driver licensing, and offer greater stability. Consumer GeForce cards can work but often need extra tweaks and lack official vGPU support.

Action items:

  1. List potential GPU models and verify vendor documentation for passthrough support.
  2. Balance workload needs against budget; enterprise cards cost more but save troubleshooting hours.

Host Platform and IOMMU Requirements

Your CPU and motherboard must expose VT-d (Intel) or AMD-Vi features. Enable them in BIOS/UEFI, then confirm the running kernel recognises an active IOMMU.
Action items:

  1. Enter BIOS, switch on VT-d/AMD-Vi.
  2. Update firmware if the option is missing.
  3. Verify with dmesg | grep -i iommu after boot.

IOMMU Groups and PCIe Topology Caveats

Devices share IOMMU groups when they cannot be isolated. If your GPU sits in a group with other critical devices, passthrough may fail.

Check groups with find /sys/kernel/iommu_groups/ -type l. If grouping is poor, move the GPU to another slot or use an ACS override patch cautiously.

Host and Hypervisor Setup: From BIOS to VFIO

With hardware cleared, configure the host to hand the GPU to the VM.

BIOS/UEFI and Boot Parameters

  1. Enable VT-d/AMD-Vi.
  2. Disable legacy VGA or “above 4G decoding” only if your board requires it.
  3. Add boot parameters such as intel_iommu=on iommu=pt or amd_iommu=on iommu=pt in GRUB, then update the bootloader and reboot

Isolating the GPU and Binding to vfio

Passthrough demands that the host never grab the GPU driver.

  1. Identify vendor and device IDs: lspci -nn.
  2. Blacklist host NVIDIA/AMD drivers.
  3. Add the IDs to the vfio-pci binding list in /etc/modprobe.d/vfio.conf.
  4. Reboot and confirm the card now shows vfio-pci with lspci -k.
    Keep a secondary GPU or onboard graphics active so you never lose host console access

Hypervisor-Specific Notes and VM Configuration

In Proxmox or pure KVM/QEMU, edit the VM’s config to attach the GPU as a PCIe device, enable PCIe ACS and reserve 16 GB of I/O memory to avoid address-space exhaustion.

Xen and other hypervisors follow the same principle: device assignment plus secure-boot nuances. After boot, run lspci in the guest to confirm the GPU is visible.
If hypervisor complexity becomes a blocker, engaging a specialist or managed provider can speed up a clean, secure deployment.

Guest OS: Installing NVIDIA Drivers, CUDA Toolkit and TensorFlow Setup

Once the VM detects the GPU, the software stack must align perfectly.

Driver and CUDA Toolkit Compatibility

Install NVIDIA drivers inside the guest first. Match the driver branch to the CUDA toolkit version your ML framework expects

  1. Run nvidia-smi to verify the card appears after driver install.
  2. Download and install the CUDA toolkit package that pairs with your driver.
    Validation: compile and run the bundled deviceQuery sample to confirm CUDA visibility.

TensorFlow Setup and Framework Configuration

Ensure the TensorFlow wheel matches your CUDA and cuDNN versions. Example (TensorFlow 2.16 with CUDA 12):

pip install tensorflow==2.16.0

Optimise runtime behaviour:

  • Set TF_FORCE_GPU_ALLOW_GROWTH=true to let memory scale gradually.
  • Restrict visible devices for multi-GPU hosts:

import tensorflow as tf gpus = tf.config.experimental.list_physical_devices(‘GPU’) tf.config.experimental.set_visible_devices(gpus[0], ‘GPU’)

Run a quick training script to confirm GPU utilisation.

Common Guest Pitfalls and Maintenance

Kernel updates can unbind VFIO modules, keep snapshots and plan patch windows. Secure Boot blocks unsigned drivers—either sign modules or disable Secure Boot in the VM. Always upgrade NVIDIA drivers and the CUDA toolkit together to avoid silent incompatibilities.

Pro Tip: Before installing a full ML stack, snapshot the VM and run only nvidia-smi plus the CUDA deviceQuery test. If anything breaks, roll back instantly and debug in isolation, saving hours of rebuild time.

Troubleshooting Common Issues

  1. GPU Visible but Not Used
    • Check nvidia-smi and framework logs for device listing.
    • Reinstall matching NVIDIA drivers or verify the correct CUDA version
  2. Driver Conflicts and Secure Boot
    • Look for host drivers loaded and Secure Boot status.
    • Sign kernel modules or disable Secure Boot for the guest.
  3. IOMMU Grouping Problems
    • Inspect the grouping output on the host.
    • Move the GPU to another slot or enable ACS override cautiously
  4. Post-Update Breakage
    • Snapshot before any kernel or hypervisor upgrade.
    • Maintain a version matrix of driver, CUDA and framework.
    • Automate validation tests (nvidia-smi + small TensorFlow script) after each reboot.

Best Practices for Production ML Workloads on Passthrough GPUs

  • Take host and VM snapshots before driver or kernel changes.
  • Monitor GPU utilisation and temperature with nvidia-smi –query-gpu.
  • Automate a tiny CUDA/TensorFlow smoke test at boot to confirm health.
  • Document the exact driver, CUDA and framework versions to accelerate on-call troubleshooting.

GPU Passthrough on VPS: Final Thoughts and Next Steps

GPU passthrough unlocks near-native performance for machine-learning workloads when hardware, hypervisor and software layers line up. Success hinges on early compatibility checks, precise host configuration and validating the guest with minimal CUDA and TensorFlow tests.

For SMEs and agencies running heavy training, the upfront effort often pays for itself. Where sharing or operational simplicity matters more, vGPU or managed cloud options still make sense.

Ready to move forward? Book a brief technical review, run your compatibility checklist and pilot a GPU-enabled VPS. If you prefer a hosted route, Vodien can provide GPU-powered instances and expert guidance; request a tailored consultation today!