Lately, I’ve been taking a journey through the various methods of GPU passthrough on a Linux host. For some reason, success eludes me on everything except for Proxmox, so I’ve settled on that for now. I’ve been posting updates around, but I figured it was time to stop crowding the other threads, and make my own. I’ll post updates here, as I make progress.
I’m going to jump ahead and assume you’ve at least brushed over the numerous guides on how to identify your gpu with lspci
and bind it to vfio.
While you can use the web interface to edit VMs, you still need to manually edit the .conf files for GPU passthrough.
Here’s a bash script I hacked together to edit .conf files in Proxmox.
#!/bin/bash
# Edits Proxmox VM entered by user.
cd /etc/pve/qemu-server
for filename in *.conf; do
cat $filename | grep name | sed "s/name:/VMID: $filename/" | sed "s/.conf/ Name:/" | sed "s/^/ /g"
done
echo "Enter the VMID you wish to edit:"
read vmid
nano /etc/pve/qemu-server/$vmid.conf
I needed to use the “romfile” parameter when passing a single gpu, but it only worked after the installation of this package found on the proxmox forums:
wget http://odisoweb1.odiso.net/qemu-server_4.0-103_amd64.deb && dpkg -i http://odisoweb1.odiso.net/qemu-server_4.0-103_amd64.deb
After installing that, edit the vmid.conf file and add (replace X and Y with your needed variables):
machine: q35
bios: ovmf
hostpci0: 0X:00,pcie=1,x-vga=on,romfile=Y.rom
That allowed me to pass my sole GPU (X99 build, so no igpu) to a VM. I’m still working on having windows pick it up, but Antergos works very well. With 2 gpus in the system, however, windows will take it just fine. Another challenge is getting any VM with a gpu passed to it to boot with more than 8 logical CPUs. My system will say it’s booting the VM, won’t give a VNC console output (it never does when it has a physical GPU), but won’t display anything either. If anyone has a solution, please let me know.
You can download a GPU rom from https://www.techpowerup.com/vgabios/
or grab your own with:
cd /sys/bus/pci/devices/0000:0X:00.0/
echo 1 > rom
cat rom > /usr/share/kvm/Y.rom
echo 0 > rom
I had to get mine from GPU-Z in windows (dual booted; not a VM), since proxmox constantly gave me a “ROM contents invalid” error. Move it to /usr/share/kvm/Y.rom
.
If that doesn’t work, add the grub boot flag video=efifb:off
It didn’t seem to make a difference for me, but it is key for others.
One more thing to note is that in my case, my connected display shows “no signal” and shuts off for 10 or so seconds before lighting back up and displaying the VM I just started. It looks like it didn’t work, but then suddenly does work, so if it doesn’t work right away, just give it a minute before you kill the VM. In my case, I’m using a GTX 980ti.
I think I’ll soon be revising this post into a guide, but for now, I wanted to get the commands and script out to those that may need it, since I’ve seen a lot of posts looking to pass a GPU to a VM. I struggled with this for a number of weeks, and am still working to troubleshoot the remaining issues. Hope it helps for now.