Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Virtualization / Hyper-V / How to Assign (Passthrough) a Physical GPU to a Hyper-V Virtual Machine

June 11, 2024

How to Assign (Passthrough) a Physical GPU to a Hyper-V Virtual Machine

The RemoteFX vGPU feature can be used in previous versions of Hyper-V (starting with Windows 7/Windows Server 2008 R2) to passthrough a host discrete GPU graphics card to a virtual machine. However, starting with Windows 10 1809 and Windows Server 2019, support for RemoteFX has been removed. Instead, the new Discrete Device Assignment (DDA) feature is proposed.


Contents:
  • Enable GPU Passthrough to Hyper-V VM on Windows Server
  • Sharing the Physical GPU with Hyper-V VM on Windows 10 or 11

Discrete Device Assignment allows physical host PCI/PCIe devices (including GPU and NVMe) to be passed through from the host to the Hyper-V virtual machine. Basic requirements for using DDA in Hyper-V:

  • Available for Hyper-V Gen 2 virtual machines only;
  • The VM must have dynamic memory and checkpoints disabled;
  • The physical graphics card must support GPU Partitioning;
  • If WSL (Windows Subsystem for Linux) is enabled on the host, a code 43 video error might occur in the VM when passing through the graphics card using GPU-P;
  • Although SR-IOV (Single Root Input/Output Virtualization) is not listed in the DDA requirements, GPU passthrough to a VM will not work correctly if it’s not supported.

Discrete Device Assignment is only available on Windows Server with the Hyper-V role. In the desktop Windows 10 and 11, you can use GPU partitioning to share the video card with the virtual machine. This article describes how to assign a physical GPU to a virtual machine on Hyper-V.

VMware PCI Passthrough (VMDirectPath) is the VMware equivalent of this feature.

Enable GPU Passthrough to Hyper-V VM on Windows Server

Discrete Device Assignment (DDA) allows PCIe devices to be passed through to a virtual machine on Windows Server 2016 and newer.

Before assigning the GPU to the VM, you must change its configuration.

Disable Hyper-V automatic snapshots for VM (described in the post Manage VM startup and boot order on Hyper-V):

Set-VM -Name munGPUVM1 -AutomaticStopAction TurnOff

Configure cache and memory limits for 32-bit MMIO space:

Set-VM -Name munGPUVM1 -GuestControlledCacheTypes $True -LowMemoryMappedIoSpace 3Gb -HighMemoryMappedIoSpace 33280Mb

Next, find out the physical path to the graphics card’s PCIe device on the Hyper-V host. To do this, open the GPU Properties in Device Manager, go to the Details tab, and find the Location Paths property. Copy the value that starts with PCIROOT.

Get GPU PCI ID name in device manager

Or use PowerShell to get this path value:

Get-PnpDevice | Where-Object {$_.Present -eq $true} | Where-Object {$_.Class -eq "Display"}|select Name,InstanceId

Disable this graphics card on the Hyper-V server in Device Manager or using PowerShell:

Dismount-VmHostAssignableDevice -LocationPath "PCIROOT(0)#PCI(0300)#PCI(0000)" –force

Now connect the physical host GPU adapter to the virtual machine:

Add-VMAssignableDevice -VMName VMName -LocationPath "PCIROOT(0)#PCI(0300)#PCI(0000)"

Then power on the VM and check that your GPU appears in the Display Adapters section of the Device Manager, along with the Microsoft Hyper-V Video device.

Assign NVIDIA GPU to a Hyper-V Virtual Machine

VM must have graphics drivers preinstalled.

To disconnect the GPU from the VM and connect it to the host:

Remove-VMAssignableDevice -VMName munGPUVM1 -LocationPath $locationPath
Mount-VMHostAssignableDevice -LocationPath $locationPath

Sharing the Physical GPU with Hyper-V VM on Windows 10 or 11

GPU Partitioning (GPU-P) is available in Hyper-V virtual machines running Windows 10/11 build 1903 or later.

Use the Get-VMPartitionableGpu (Windows 10) or Get-VMHostPartitionableGpu (Windows 11) command to check if your graphics card supports GPU partitioning mode.

Get-VMHostPartitionableGpu - list GPUs available for partitioning in the Hyper-V host

Use the Add-VMGpuPartitionAdapter cmdlet to pass through the video adapter from the host to the VM. Copy the drivers for the graphics card from the Hyper-V host to a virtual machine using the Easy-GPU-PV script (https://github.com/jamesstringerparsec/Easy-GPU-PV).

Download the ZIP archive containing the script and extract it to a folder on the Hyper-V host.

Download Easy-GPU-PV PowerShell script - allows to partition your GPU and assign it to Hyper-V VMs

Open an elevated PowerShell console, then allow running PowerShell scripts in the current session.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass –Force

Run the script:

.\Update-VMGpuPartitionDriver.ps1 -VMName myVM1 -GPUName "AUTO"

The script copies the GPU drivers from the host to the VM.

Update-VMGpuPartitionDriver.ps1 - copy video driver from host to VM

Now change the VM settings and assign the GPU to it:

Set-VM -VMName myVM1-GuestControlledCacheTypes $true -LowMemoryMappedIoSpace 1Gb -HighMemoryMappedIoSpace 32Gb
Add-VMGpuPartitionAdapter -VMName myVM1

If you have updated the video drivers on the Hyper-V host, you must also update them on the virtual machine.

.\Update-VMGpuPartitionDriver.ps1 -VMName myVM1 -GPUName "AUTO"

4 comments
11
Facebook Twitter Google + Pinterest
Hyper-VPowerShellWindows 10Windows 11Windows Server 2019
previous post
Printing from Linux to a Windows Shared Printer
next post
How to Add or Remove Pinned Folders to Quick Access with PowerShell and GPO

Related Reading

How to Enable and Configure Hyper-V Remote Management

June 8, 2023

How to Install and Configure Free Hyper-V Server...

March 16, 2024

Poor Network Performance on Hyper-V VMs in Windows...

February 20, 2023

Windows Cannot Find the Microsoft Software License Terms

April 19, 2023

Enable Hyper-V on Windows 10/11 Pro and Home...

August 12, 2024

Configure SR-IOV for Hyper-V Virtual Machines on Windows...

March 29, 2022

Hyper-V Virtual Machine Stuck in Stopping/Starting State

March 16, 2024

Import, Export and Clone Virtual Machines in Hyper-V

January 19, 2022

4 comments

dk June 14, 2024 - 11:46 am

I finally got it working, including the games! I could separate gaming and work on two PCs.
I don’t agree with those who say “Hyper-V is not for graphics”.
On VMware Workstation pro, I experienced frequent crashes, slowdowns and freezes in games and applications such as FreeCad, Slash3D, Blender and Adobe.
Thank the author for writing this!

Reply
Wk June 15, 2024 - 3:46 pm

I`m receiving the followed erro when try to dismount the GPU.
I had take a lot of time searching for ACS at BIOS, withour sucess.
I don`t know how to enable it.
Please, help me.
My mother board is a ROG STRIX Z370-H GAMING, BIOS ver: 2701, no update available.

Dismount-VmHostAssignableDevice : The operation failed.
The PCI Express bridges between this device and memory lack support for Access Control Services, which is necessary for securely exposing this device within a virtual machine.
At line:1 char:1
+ Dismount-VmHostAssignableDevice -LocationPath “PCIROOT(0)#PCI(0101)#P …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Dismount-VMHostAssignableDevice], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.DismountVMHostAssignableDevice

Reply
admin June 20, 2024 - 11:02 am

The motherboard chipset must have: access control services (ACS) on PCI Express root ports
And check that your CPU supports SLAT, Intel VT-d2 or AMD I/O MMU, and EPT (in case of Intel CPU)

Reply
JLopes June 16, 2024 - 8:23 pm

I had follow all steps from your guid, but at the and, after the command: Add-VMAssignableDevice -VMName VMName -LocationPath “PCIROOT(0)#PCI(0300)#PCI(0000)”.
I remount the device (GPU) and VM return to normal.

The Following Error ocurring:
How can I solve these problem?

Couldn’t start virtual machine

5:18:51 PM
Source
Go to Virtual machines.
Type
Error

Message
RemoteException: Failed to start virtual machine W10-AA. Error: ‘W10-AA’ falhou ao inicializar.

Virtual Pci Express Port (ID de Instância 9F2C1609-E884-4435-AFF6-AC765B1A804F): falha ao ligar com o Erro ‘A hypervisor feature is not available to the user.’.

‘W10-AA’ falhou ao inicializar. (ID da máquina virtual BF829271-2322-4396-8CB1-69637772D034)

‘W10-AA’ Virtual Pci Express Port (ID da instância 9F2C1609-E884-4435-AFF6-AC765B1A804F): falha ao ligar com o erro ‘A hypervisor feature is not available to the user.’ (0xC035001E). (ID da máquina virtual BF829271-2322-4396-8CB1-69637772D034)

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Enable and Configure Hyper-V Remote Management
  • Enable Hyper-V on Windows 10/11 Pro and Home Editions
  • Attaching Host USB Devices to WSL or Hyper-V VM
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top