Adding Nvidia GPU Passthrough on a MicroK8s virtual machine hosted on Proxmox

Proxmox VM Configuration: 

  1. Create a New VM: Create a new Linux VM (e.g., Ubuntu 22.04/24.04 LTS). Use OVMF (UEFI) for BIOS and Qemu Agent in the System tab for better compatibility.
  2. Edit VM Configuration: Before starting the VM, edit its configuration file (/etc/pve/qemu-server/XXX.conf, where XXX is the VM ID) to add CPU: host,hidden=1 to improve compatibility.
  3. Add the PCI Device: In the Proxmox Web UI, go to the VM’s Hardware tab and select Add > PCI Device.
    • Select your NVIDIA GPU from the drop-down list.
    • Check All functionsPrimary GPU (if it’s the only one), and PCI-E.
  4. Set Display to none: Change the Display option to none to prevent conflicts with the passed-through GPU. You will need SSH or a separate VNC/RDP client to access the VM. 

MicroK8s and AI Setup (within the VM) 

  1. Install NVIDIA Drivers: Inside the VM, install the appropriate NVIDIA guest drivers matching your GPU model.
  2. Install MicroK8s: Follow the official guide to install MicroK8s within the VM.
  3. Enable NVIDIA Gpu Addon: Use the MicroK8s command to enable the NVIDIA GPU acceleration addon, which installs necessary components like the NVIDIA device plugin for Kubernetes to recognize and utilize the GPU. Command – microk8s enable gpu
  4. Verify: Run nvidia-smi in the VM console to confirm the GPU is recognized and working, and use microk8s kubectl get nodes -o wide and check the allocatable resources to ensure the GPU is available to the Kubernetes cluster. 

For more detailed, step-by-step Proxmox configuration, consider following the guides on the Proxmox Wiki