We are presenting to you a guide regarding GPU passthrough created in collaboration with peers.
Qubes OS already has extensive documentation available about GPU passthrough for 3D accelerated tasks but they all require in depth configuration, extra displays, and extra input devices. With VirtualGL (https://virtualgl.org) one can take advantage of the existing Qubes OS framework for audio/display by offloading OpenGL onto the secondary graphics card directly with VirtualGL. This document will mostly be working off of the Neowutran (Qubes OS article) guide with a few tweaks.
Casual applications will work but some games require capturing the mouse cursor and Qubes OS doesnât support this, so the camera will not work with the emulated input device. An extra gamepad etc. will probably be desired.
Device compatibility:
Nvidia: Works but lower FPS reported on Nouveau/Mesa driver, proprietary driver is fine.
AMD: Working with Mesa after disabling MSI in template kernel command line with parameter pci=nomsi. Conflicts occurred having Nvidia drivers installed with the AMD card, VirtualGL reports no EGL devices while they are installed. A simple fix is possibly preloading the proper libraries.
Both graphics cards seem to support Xenâs memory balancing, but only up to the amount of initial memory at boot.
Instructions:
Edit GRUB configuration in /etc/default/grub to restrict the secondary graphics card from dom0 with the rd.qubes.hide_pci kernel option. Reconfigure GRUB with grub2-mkconfig -o /boot/grub2/grub.cfg. Reboot.
Create a new template to hold graphics drivers and VirtualGL configuration.
Follow the instructions to install desired graphics drivers for the specific OS template.
Download VirtualGL from its SourceForge repository and install it to the template.
Run vglserver_config as root and configure for EGL, respond no to the prompt about framebuffer access.
Edit /etc/profile and append export VGL_DISPLAY=egl to the bottom.
Shutdown the template. Create a new VM from it. Set virtualization mode to HVM and kernel to Qube provided. Attach secondary graphics card to it. Boot, and execute vglrun with a command to get accelerated graphics. Wrapping a shell also works (vglrun bash) to avoid having to type it every time, but there is no obvious way to automate this at startup.
From VirtualGL - ArchWiki :
Tip:
vglrun
is actually just a shell script that (temporarily) sets some environment variables before running the requested application - most importantly it adds the libraries that provide all the VirtualGL functionality toLD_PRELOAD
. If it better suits your workflow, you could just set those variables yourself instead. The following command lists all environment variables that vglrun would set for your particular set-up:comm -1 -3 <(env | sort) <(vglrun env | grep -v â^[â | sort)
Donations:
We are no longer accepting donations, and have moved on to other projects. We will not be able to adequately respond to further questions. The follow up information provided by users appears to be sufficient for now.