Skip to content

How to share your intel gpu with multiple VMs on proxmox

Posted on:September 5, 2022 at 12:00 AM

Now you can with the magic that is SR-IOV if you have a intel GPU! (results may vary depending on your GPU, mine is a 12gen intel GPU, UHD Graphics 770)

Do you have NVIDIA or AMD instead? For the first, pay up for enterprise stuff (or use hacks such as this one on supported architectures) and for the latter the answer is to get f****d as the GPUs from AMD that support SR-IOV can be counted with two hands and are enterprise ones anyway.

Until a few months ago there was basically no support (and there still is no support) and a custom intel kernel was needed as even if you enabled the feature, the linux i915 driver (which is needed in the host) would not be able to create the multiple virtual devices. Fortunately this has changed and an experimental DKMS module has been made which works on the pve-kernel-6.1.0-1-pve kernel correctly at the time of writing.

Note: At the time of writing the 6.1 kernel seems to be mandatory and it’s not yet in production so there could be some bugs, but you can ignore that and do:

Of course there was no installation guide on the github page, otherwhise where would the fun be? (Experienced linux developers might know how to compile and install a DKMS module manually, but I didn’t)

Fortunately, the AUR package had an install script so I just reversed it, which boils down to:

  1. git clone https://github.com/strongtz/i915-sriov-dkms
  2. Edit the @_PKGBASE@ and @PKGVER@ values with the ones provided in the install script in the dkms.conf file
  3. Copy the folder to /usr/source as /usr/src/${_pkgbase}-${pkgver}
  4. Set permissions for the folder and all files to 755 and permissions for the dkms.conf file to 644
  5. dkms install -m i915-sriov-dkms -v ${pkgver}
  6. Edit the /etc/kernel/cmdline file (I use zfs on proxmox with systemd-boot, you might have the kernel arguments in a different place) and add intel_iommu=on i915.enable_guc=7 (The repository does not use it but I also have iommu=pt there)
  7. Refresh the kernel arguments via proxmox-boot-tool refresh (see the documentation if you’re not using systemd-boot)
  8. apt install sysfsutils
  9. Create the virtual devices permanently echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 7" > /etc/sysfs.conf (check if your intel GPU is at 0000:00:02.0 via lspci -v)
  10. Reboot

If everything went well by doing lspci you’ll now have something like this!

You can now add it to your virtual machine like it was a PCI device. (Note: I had to install the recommended driver for Windows from this page)

For future updates this thread would be an interesting thread to follow.