A hardware GPU may be shared by several virtual machines (VMs) via GPU partitioning, which is supported by Hyper-V on Windows Server as of my most recent update in September 2021. DDA stands for Discrete Device Assignment, and it is this functionality. You may grant a virtual machine (VM) direct access to the GPU by using DDA.
To share a GPU in Hyper-V via Discrete Device Assignment, follow these steps:
First requirements:
Verify that the chipset and motherboard in your computer support I/O MMU, such as AMD-Vi and Intel VT-d.
Make sure your GPU is DDA compliant. This capability isn’t supported by every GPU.
There can be only Generation 2 VMs.
2. Get the host ready:
Since a GPU cannot be utilized by both the host and the virtual machine (VM) at the same time, the host must disable the GPU.
Disable-PnpDevice -InstanceId “PCI\VEN_XXXX&DEV_XXXX&SUBSYS_XXXXXXXX&REV_XX\X&XXXXXXX&X&XX” -Confirm:$false
Replace the instance ID with the appropriate value of your GPU. You can find the instance ID from Device Manager or use Get-PnpDevice.
Enable the Hyper-V VM settings for DDA:
Set-VM -GuestControlledCacheTypes $true -VMName <your_vm_name>
Set-VM -LowMemoryMappedIoSpace 3Gb -VMName <your_vm_name>
Set-VM -HighMemoryMappedIoSpace 33280Mb -VMName <your_vm_name>
3. Assign the GPU to the VM:
Determine the location path for the GPU:
Get-PnpDevice | Where-Object {$_.Class -eq “Display” -and $_.Status -eq “OK”}
Note down the LocationPaths of the GPU.
Assign the GPU:
Add-VMAssignableDevice -LocationPath “PCIROOT(0)#PCI(0300)#PCI(0000)” -VMName <your_vm_name>
4. Start the VM:
Now, start the VM. Once the VM is running, you can install the GPU drivers inside it, just like you would do on a physical machine.
5. To remove the GPU from the VM:
If you want to revert and remove the GPU from the VM:
Remove-VMAssignableDevice -LocationPath “PCIROOT(0)#PCI(0300)#PCI(0000)” -VMName <your_vm_name>
Remarks:
By avoiding the Hyper-V virtualization stack, DDA allows the virtual machine to have direct access to the GPU. As a result, when the host system’s GPU is allocated to a virtual machine, it cannot be used.
Although DDA makes it possible for numerous virtual machines to share a GPU, there are performance issues to be mindful of, particularly if the GPU isn’t capable of hardware partitioning.
Always make a backup of your important data before performing any big system setup adjustments.
When following these instructions, make sure you’re using the latest official Microsoft documentation to guarantee accuracy and take into account any changes made after 2021.