How to Configure GPU Passthrough on Hyper-V with Discrete Device Assignment (DDA): Assigning a Physical GPU Directly to a Windows Server VM

Virtualization tutorial - IT technology blog
Virtualization tutorial - IT technology blog

Want to run AI inference, render video, or use CAD software inside a Hyper-V virtual machine? You’ll quickly discover that the default virtual display adapter (Microsoft Hyper-V Video) can only handle basic 2D graphics. Any workload requiring CUDA or heavy DirectX gets offloaded to the CPU, resulting in constant VM stuttering or errors stating that no GPU was found.

In my homelab, I use Proxmox VE to manage 12 VMs and containers for testing before pushing anything to production. When moving to an enterprise infrastructure running Windows Server, the exact same challenge comes up. Since Microsoft retired RemoteFX vGPU due to security vulnerabilities, Discrete Device Assignment (DDA) is the only remaining way to pass a physical graphics card directly into a virtual machine.

Quick start: Assign a GPU to a Hyper-V VM in 5 minutes

Before running any commands, check three prerequisites: the physical host must have Intel VT-d (or AMD-Vi), SR-IOV, and Above 4G Decoding enabled in the BIOS. The target VM should be Generation 2 and in a powered-off state (Off). Finally, the GPU you plan to assign cannot be the only card driving the host’s display output.

Once that’s ready, open PowerShell as Administrator on the Windows Server Host and run the following commands in order:

# 1. Find the name and LocationPath of the physical GPU
Get-PnpDevice -Class Display | Select-Object FriendlyName, InstanceId, Status

# Replace InstanceId with your actual device ID to get the LocationPath
$pnpDevice = Get-PnpDevice -InstanceId "PCI\VEN_10DE&DEV_2204&SUBSYS_..."
$locationPath = ($pnpDevice | Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationPaths).Data[0]
Write-Host "LocationPath: $locationPath"

# 2. Disable the GPU on the Host and dismount it from Host control
Disable-PnpDevice -InstanceId $pnpDevice.InstanceId -Confirm:$false
Dismount-VMHostAssignableDevice -Force -LocationPath $locationPath

# 3. Configure the VM (replace 'VM-AI-01' with your VM name)
$vmName = "VM-AI-01"
Set-VM -Name $vmName -AutomaticStopAction TurnOff
Set-VM -VMName $vmName -GuestControlledCacheTypes $true
Set-VM -VMName $vmName -LowMemoryMappedIoSpace 3GB
Set-VM -VMName $vmName -HighMemoryMappedIoSpace 32GB

# 4. Assign the GPU directly to the VM and start it
Add-VMAssignableDevice -VMName $vmName -LocationPath $locationPath
Start-VM -Name $vmName

Wait for the VM to boot, then connect via Remote Desktop (RDP) and open Device Manager. You’ll see your GPU listed under Display adapters. From there, simply install the NVIDIA or AMD drivers just like you would on a physical machine.

Deep dive: The problem, the cause, and how DDA solves it

Running a few commands that work is one thing. However, if you hit an error halfway through, you need to understand what each PowerShell line is actually doing under the hood.

1. Why can’t a VM automatically use the Host’s GPU power?

Hyper-V places a virtualization layer (hypervisor) between the physical hardware and the Guest OS. This layer can easily share CPU and RAM across multiple VMs. However, sharing a PCIe device like a GPU directly is much more complex. Previously, Windows Server offered RemoteFX vGPU so multiple VMs could share a single card, but Microsoft completely removed it from Windows Server 2019 (via updates) and 2022 for security reasons.

2. How Discrete Device Assignment (DDA) works

In principle, DDA works similarly to VFIO PCI Passthrough on Linux KVM. Leveraging hardware-level I/O virtualization (Intel VT-d or AMD-Vi), the Dismount-VMHostAssignableDevice command severs the Windows Server Host’s access to the PCIe slot housing the GPU. Hyper-V then maps the card’s memory regions and interrupts directly into the address space of a single VM.

The Guest OS inside the VM sees the actual physical hardware. Performance reaches around 98-100% of bare-metal levels because there is no intermediate emulation layer.

3. What the VM configuration parameters mean

  • AutomaticStopAction TurnOff: When a VM holds physical hardware, Hyper-V cannot save RAM state to disk (Save State) during host shutdown. You must set the stop action to TurnOff, otherwise the device assignment command will immediately fail.
  • GuestControlledCacheTypes $true: Allows the Guest OS to control memory caching behavior between the CPU and GPU, preventing bottlenecks or driver crashes.
  • LowMemoryMappedIoSpace and HighMemoryMappedIoSpace: These two parameters allocate MMIO space to map the GPU’s VRAM and registers. If you allocate too little, Device Manager inside the VM will report Code 12 (This device cannot find enough free resources).

Advanced: Checking hardware compatibility and troubleshooting

Checking if your server supports DDA

Not every motherboard and graphics card supports DDA seamlessly. Some budget motherboards fail to isolate IOMMU groups (ACS – Access Control Services) or lack the necessary device mapping tables in the BIOS. You can run a quick check with these two PowerShell commands:

# List devices ready for DDA on the Host
Get-VMHostAssignableDevice

# Check whether the VM has received the device
Get-VMAssignableDevice -VMName "VM-AI-01"

Want a deeper look into your motherboard’s PCIe isolation capabilities? Microsoft provides the SurveyDDA.ps1 script on its official GitHub repository. It scans all PCIe slots and outputs a detailed report on which devices meet DDA requirements.

Calculating HighMemoryMappedIoSpace for high-VRAM GPUs

The 32GB value in the Quick start section is only enough for 8GB–16GB VRAM cards like the RTX 3060, RTX 4080, or Tesla T4. If you’re passing through an RTX 3090, RTX 4090 (24GB VRAM), or NVIDIA A100 (40GB/80GB VRAM), 32GB will fall short right away.

A safe rule of thumb is to set HighMemoryMappedIoSpace to 1.5x to 2x the total VRAM, then round up to the next power of 2. For example, a 24GB VRAM card needs 64GB, while an A100 80GB should be given 128GB or 256GB. For a 24GB VRAM GPU, update the setting like this:

Set-VM -VMName "VM-AI-01" -HighMemoryMappedIoSpace 64GB

How to remove the GPU from the VM and return it to the Host

When you need to reclaim the GPU for the Host or move it to another VM, shut down the VM first before removing the device:

Stop-VM -Name "VM-AI-01"
Remove-VMAssignableDevice -VMName "VM-AI-01" -LocationPath $locationPath
Mount-VMHostAssignableDevice -LocationPath $locationPath
Enable-PnpDevice -InstanceId $pnpDevice.InstanceId -Confirm:$false

Practical tips for running GPU Passthrough on Windows Server

  • Always keep a display output for the Host: Never dismount the only GPU on your server if you don’t have IPMI, iDRAC, or iLO. The moment Dismount-VMHostAssignableDevice finishes, any monitor plugged into that card will go black. Ideally, use the CPU’s integrated graphics (iGPU) or install an inexpensive secondary card for the Host.
  • No Checkpoints or Live Migration: A VM holding a DDA device loses Hyper-V Checkpoint support and cannot be Live Migrated to another node. You’ll need to back up data directly inside the Guest OS or shut down the VM completely before backing up the VHDX file.
  • Use proper remote access tools: Hyper-V’s default console window (VMConnect) doesn’t leverage the passed-through GPU for frame acceleration. If you’re using the VM for rendering or interactive graphics work, install Parsec, Moonlight, or enable GPU acceleration for RDP. Also, plug an HDMI Dummy Plug into the physical card if you need high-resolution output.
  • Watch out for Code 43 on GeForce cards: NVIDIA previously blocked passthrough on GeForce cards to push users toward Quadro or Tesla lines. Starting with driver release R465, NVIDIA officially unlocked passthrough support for VMs. Be sure to download the latest driver package if you encounter Error Code 43 in Device Manager.
Share: