X server on virtual machine with accelerated rendering

I have an Ubuntu 22.04 virtual machine running on the KVM hypervisor with PCIe passthrough of an RTX A5000. The Xfce environment is installed and I’m accessing it graphically via the console feature of the hypervisor (not VNC or otherwise).

I have the GPU driver installed and nvidia-smi is happy. However, when I run benchmarks like glmark2, they use the llvmpipe renderer. The Xorg process shows up in nvidia-smi’s process list, but the other apps don’t.

This sent me down a rabbit hole of trying to figure out: Can I use my GPU to render graphics, while still outputting to the console? For example, can I have accelerated OpenGL rendering with full support for shaders, etc.?

I started with nvidia-xconfig but when I didn’t have any luck I pared it down to:

Section "Monitor"
    Identifier     "Monitor0"

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"

When I start X, there are no logged errors. The console stops updating but does not show my login window.

I suspected it might be trying to output over the GPU’s HDMI ports. I added Option "UseDisplayDevice" "None" to the Device section to try to discourage that, without any change.

Is this achievable?

nvidia-bug-report.log.gz (432.8 KB)

This depends on the capabilities of the virtual vga drm driver. You can try if offloading works. Please run
and check if nvidia-smi shows glxgears in its process list. You might have to set kernel parameter nvidia-drm.modeset=1

Yes, that does get it into the nvidia-smi process list, without needing to modify the kernel command line.

Could you please explain what offloading does?

Should I add those to /etc/environment or is there a better way to make this configuration stick?

PRIME render offload uses one gpu to render and then transports the result to another gpu for display, application-based. Setting that in env is possible but awkward, not recommended. For an alternative, you could check if the virtual drm driver also supports prime output, please post the output of
xrandr --listproviders

$ DISPLAY=:0 xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x40 cap: 0x0 crtcs: 1 outputs: 1 associated providers: 0 name:modesetting
Provider 1: id: 0x227 cap: 0x2, Sink Output crtcs: 4 outputs: 8 associated providers: 0 name:NVIDIA-G0

Since the modesetting provider would need to have the “Sink Output” capability for prime output, you’re limited to use render offload.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.