How to Connect a Physical GPU to a Virtual Machine on Hyper-V

Key Notes

  • GPU Passthrough improves virtual machine graphics performance.
  • System requirements include Intel-VT or AMD-V support.
  • Proper configuration is essential for successful GPU allocation.

Maximize Virtual Graphics: A Comprehensive Guide to Attaching a Physical Video Card on Hyper-V

For advanced users requiring robust graphics in virtual environments, leveraging a dedicated GPU can significantly enhance performance in applications like gaming or intensive graphical computations. This guide details how to attach a physical video card to a VM on Hyper-V, exploring prerequisites and step-by-step procedures while shedding light on potential pitfalls.

How to Attach a Physical Video Card to a VM Using GPU Passthrough

Follow these detailed steps to attach a physical video card to a VM via GPU Passthrough:

  1. Enable Intel-VT or AMD-V Virtualization.
  2. Configure Your Computer for GPU Passthrough.
  3. Set Up GPU Passthrough for Windows 11/10.
  4. Set Up GPU Passthrough for Windows Server.

Step 1: Enable Intel-VT or AMD-V Virtualization

Initially, you must enable hardware virtualization. For Intel CPUs, enable Intel-VT, while AMD-V Virtualization applies for AMD users. Access the BIOS settings by restarting the computer:

Navigate to Configuration > Virtualization Technology and set it to Enabled.

Step 2: Configure Your Computer for GPU Passthrough

With virtualization enabled, you must ensure the host is configured accordingly. Validate that IOMMU is active and automatic checkpoints are disabled. You can use PowerShell to check IOMMU status:

(Get-VMHost).IovSupport; (Get-VMHost).IovSupportReasons

If it returns True, proceed; if False, enable it. Next, delete all VM checkpoints:

Get-VM | Set-VM -Name NameOfVM -AutomaticStopAction TurnOff

Step 3: Set Up GPU Passthrough for Windows 11/10

To enable GPU Passthrough for client operating systems, check if your video card supports it:

For Windows 11: Get-VMHostPartitionableGpu

For Windows 10: Get-VMPartitionableGpu

Next, download and extract the graphics driver required using this link.

Enable script execution with:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force and Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

To add a VM to GPU Passthrough, execute:

.\Update-VMGpuPartitionDriver.ps1 -VMName <VMNAME> -GPUName "AUTO"

Step 4: Set Up GPU Passthrough for Windows Server

For Windows Server, configure cache and limits:

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

Determine the PCI Express device location with:

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

If located, proceed to disable the device in Device Manager, run:

Dismount-VmHostAssignableDevice -LocationPath "PCIROOT(0)#PCI(0200)"-Force

To assign the GPU:

Add-VMAssignableDevice -VMName VMNAME -LocationPath "PCIROOT(0)#PCI(0200)"

Boot up the VM, install the video card drivers from the manufacturer’s website, and you are set!

To remove the GPU from the VM, execute:

Remove-VMAssignableDevice -VMName VMNAME -LocationPath $locationPath

Finally, reconnect the GPU:

Mount-VMHostAssignableDevice -LocationPath $locationPath

Summary

Successfully attaching a physical video card to a virtual machine on Hyper-V through GPU Passthrough unlocks unparalleled graphics performance for demanding applications. Ensure hardware and software prerequisites are met, enable virtualization, and follow detailed configuration steps to maximize your VM’s capabilities.

Conclusion

By integrating a physical video card into your virtual environment, you enhance your system’s graphical capabilities, opening up new avenues for gaming, design, and data visualization tasks. Follow the outlined steps carefully for a successful setup, ensuring that you adhere to hardware and software requirements. Empower your virtual machines today!

FAQ (Frequently Asked Questions)

What is GPU Passthrough?

GPU Passthrough is a technology that allows a virtual machine direct access to a dedicated graphics card, improving its performance for applications that need high graphical processing power.

Can any GPU be used for Passthrough?

No, you must ensure that the GPU supports virtualization technologies such as NVIDIA GRID or AMD MxGPU for successful passthrough.