Windows & Codex

I Wanted My Radeon GPU Inside a Hyper-V Linux VM, So I Wrote Down How

I wanted a Linux desktop inside a Hyper-V virtual machine, and I wanted it to use my AMD Radeon GPU.

That sounds like a reasonable thing to ask for. In practice a normal Hyper-V Linux guest has no real GPU. The desktop renders in software, and remote desktop encodes every frame on the CPU. It works, but a 1440p session quietly eats cores, and anything that needs OpenGL feels like it is wading through mud.

Most of what I could find about GPU partitioning assumed an NVIDIA card or a Windows guest. For a Radeon in an Ubuntu VM there were scattered pieces and no complete path, so I put one together and wrote it down: hyperv-linux-amd-gpu-pv.

It is a technical preview, not a polished installer. I will get to the limits at the end, because they matter.

What this is, and what it is not

Three questions come up immediately, so here are the answers up front.

  • Is it a normal Hyper-V VM? Yes. It is a Generation 2 Ubuntu guest, not WSL2.
  • Is it PCIe passthrough? No. GPU-PV partitions the GPU, so Windows keeps using the same card while the guest borrows a slice of it.
  • Is it supported by Microsoft or AMD? No. It is a community configuration on a consumer card. If you need supported GPU partitioning, use the hardware and operating systems Microsoft documents.

Three separate pieces

The project looks like one thing from the outside, but it is three parts that can be used independently.

1. GPU-PV in the guest. The guest loads dxgkrnl, Mesa’s D3D12 driver, and user-mode libraries that you copy from your own Windows installation. After that, applications can use the partitioned Radeon through /dev/dxg for OpenGL and VA-API. On the reference machine that gives OpenGL 4.6 with the renderer reported as D3D12 (AMD Radeon RX 6900 XT).

2. Hardware encoding for remote desktop. A patched GNOME Remote Desktop hands frames to a separate encoder helper. The helper uses the AMD H.264 encoder through Mesa D3D12 and VA-API, and the daemon sends the result over RDP as AVC420 or AVC444v2.

3. Optional desktop and clipboard fixes. A scoped systemd configuration can render the headless GNOME Shell through D3D12, and a separate patch series improves clipboard interoperability with Windows RDP clients for text, images, HTML and Unicode.

Desktop rendering and RDP encoding do not depend on each other. You can enable either one without the other.

AMD GPU-PV for Hyper-V Linux VMs project overview

Why the encoder is a separate helper

The obvious design is to put the encoder inside GNOME Remote Desktop and share GPU frames directly. I did not do that, for a practical reason: GPU interop is not reliable inside a GPU-PV guest, and when it goes wrong it can take the whole daemon down with it.

Instead the daemon passes shared-memory NV12 frames to a helper process. It is not zero-copy, and that is deliberate. The cost is a copy; the benefit is that a driver fault or a helper crash is contained. If the helper times out or dies, the daemon falls back to x264 software encoding instead of dropping the session.

What it buys you

I measured it, with the caveat that these numbers are one workload on one machine. They show what the hardware path saves on this rig, not a general ranking of codecs.

1080p Encoder CPU (cores) Bandwidth
Stock RFX Progressive 1.39 81.5 Mbit/s
Software x264 AVC444v2 1.34 7.3 Mbit/s
Hardware AVC420 0.41 3.7 Mbit/s
Hardware AVC444v2 0.55 3.4 Mbit/s

Against software x264 with the same AVC444v2 format, hardware encoding used about 59% less encoder CPU at 1080p and about 53% less at 1440p, with essentially the same chroma quality on coloured text. Against the stock RFX path the bandwidth drops by more than 90%. Frame rates were comparable across the encoders in these runs.

Bar chart of encoder CPU cores at 1080p and 1440p for RFX, software x264, hardware AVC420 and hardware AVC444v2
Encoder CPU in cores. Hardware AVC420 and AVC444v2 sit well below RFX and software x264 at both resolutions.

AVC420 is the cheapest, but its colour fidelity is clearly lower: the chroma figures for coloured text were about 22 to 24 dB, against about 35 dB for AVC444v2. Text and UI are where you notice. One honest footnote: AVC444v2 here is two H.264-compatible 4:2:0 views, a main and an auxiliary one. It is not native 4:4:4 hardware encoding.

Switching modes

I wanted a way out that does not require remembering anything while something is broken. There is one small control script:

gpupv-ctl status
gpupv-ctl avc444    # best colour detail, if the client supports it
gpupv-ctl avc420    # lower colour detail, lower resource use
gpupv-ctl software  # x264, no GPU encoder
gpupv-ctl rollback  # back to the distribution's stock daemon

status reports both the configured mode and the encoder that is actually in use, which turned out to matter more than I expected. A silent fallback to x264 looks exactly like a working hardware path until you look at CPU usage.

Where it gets awkward

The checks that were most useful to me were two commands: glxinfo should show a renderer containing D3D12 (AMD Radeon ...), and vainfo should list an EncSlice entrypoint. If you see llvmpipe, that command is still using software rendering. For hardware encoding you also need AMD’s libamdenc64.so next to amdxc64.so; without it the VA-API driver only offers decode.

Do not set GALLIUM_DRIVER=d3d12 globally. It makes gnome-remote-desktop crash, and it is why the configuration in the project is scoped to specific services.

The project does not ship any Microsoft or AMD driver files. You copy them from your own Windows installation, and you should not commit or share them. After a host driver update the DriverStore directory name changes, so the files have to be refreshed.

What I have not verified

This is a release candidate and I want to be direct about it:

  • The full setup was demonstrated on one machine: a Ryzen 9 5900XT, a Radeon RX 6900 XT, a Windows 11 host and an Ubuntu 26.04.1 guest. Other GPUs, drivers and guests are untested.
  • The host PowerShell scripts have not been run on a real Windows host yet, and the guided installer has not been run end to end on a fresh VM. Use -WhatIf and --dry-run first. The manual procedure is the validated reference.
  • H.264 only. HEVC encode hung on this stack, and AV1 was not tested.
  • It is not SR-IOV, not live-migratable, and not highly available.

If you try it on different hardware, the repository has a compatibility matrix and a reporting template, and that kind of report is the most useful thing anyone can send.

Project: github.com/tuolaji996/hyperv-linux-amd-gpu-pv

Leave a comment

Your email is never shown. New comments may be held for review.