Using Nvidia GPU as primary GPU in HVMs with pci passthrough to fix screen tearing

Hello,
I just installed Qubes OS and don’t fully understand how it works so please correct me if I say something wrong.

I just made a template (from the debian-12 template) with the nvidia drivers installed so I can stream videos lag-free but I get severe screen tearing and videos are choppy no matter how low the quality is or how much ram/cores I give to the qube.
I am sure my GPU is used by whatever app I use to play my video (using “__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia”).
I tried with chromium and mpv with various settings/configurations (the performances are good, I can play 4k fine) but the issue persists (micro lags every 20 frames and tearing).
To fix this issue (after trying all the fixes online) I tried to set my GPU as the main device for the X server inside my cube by following NVIDIA Optimus - Debian Wiki .
This failed because this device:
00:03.0 VGA compatible controller: Device 1234:1111 (rev 02)
Subsystem: Red Hat, Inc. Device 1100
Kernel driver in use: bochs-drm
Kernel modules: bochs

always gets picked whatever I do instead of my nvidia gpu.
I tried everything, even deleting “nomodeset” from the default kernelopts and setting the qube kernel to “provided by qube” and then reinstalling the driver.

Is what I’m trying to do even achievable ?
If not, is there any other way I can get rid of the tearing inside my HVM cubes ?

Thanks.

1 Like

No template. Standalone only.

This is not true. You can use an appvm with GPU pass through, this is how sys-net works with the networking devices pass through.

But for OP question, if you get it to work (it’s hard), you will be able to only use a single qube at a time.

1 Like

Why ?

*I don’t see how it would makes other qubes unusable.
Also OP said that it is working but the gpu isn’t used by default by the apps inside the cube.

You can only pass a device to one qube at a time. A device can’t be used by the two operating systems simultaneously.

Yes but this is not what the post is about.