Quick Bites:

  • The blog post provides a comprehensive guide on enabling GPU passthrough in Microsoft Hyper-V, highlighting its benefits, requirements, and setup process
  • It explains how GPU passthrough enhances graphics performance for virtual machines, making it suitable for intensive tasks like gaming, video editing, and CAD
  • The post outlines the necessary hardware and software requirements, steps to configure GPU passthrough, and also mentions the limitations and challenges associated with its use

One of the really cool capabilities of modern virtualization environments like Hyper-V is the ability to passthrough physical hardware to the virtual machines running on top of the hypervisor. This capability provides many benefits compared to using only virtual hardware that helps meet certain use cases.

One of these that Hyper-V supports is GPU passthrough, a feature that allows virtual machines to access the host’s GPU directly. Let’s look at Hyper-V GPU passthrough for beginners and see how this feature allows Hyper-V admins to provide discrete graphics hardware to virtual machines.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Table of Contents

  1. What is GPU Passthrough?
  2. Benefits of GPU Passthrough in Hyper-V
  3. Requirements for Hyper-V GPU passthrough
  4. Hardware Requirements
  5. Software Requirements
  6. Overview of Enabling Hyper-V GPU passthrough
  7. Unsupported configurations and limitations to note
  8. Challenges of GPU Passthrough in Hyper-V
  9. Hyper-V GPU passthrough FAQs
  10. Wrapping up

What is GPU Passthrough?

Normally, in virtualized environments, virtual machines rely on the Hyper-V host’s CPU for graphics processing power. While this works for basic virtual machine use cases, it isn’t very powerful for more intensive graphics needs. GPU passthrough is a capability allowing Hyper-V admins to pass the graphics processing unit (GPU) from the physical Hyper-V host to virtual machines running in the Hyper-V environment. It allows VMs to have access to physical graphics cards for graphics intensive workloads and even machine learning workloads that are growing in demand today.

Graphics intensive workloads like gaming or video editing usually require dedicated, standalone machines with discrete graphics cards. However, with GPU passthrough, these types of applications are possible on virtual machines and can solve the challenge of VDI environments for graphics designers, engineers, and others who require a lot of graphics processing power.

Download Banner

Benefits of GPU Passthrough in Hyper-V

There are several benefits to using GPU passthrough in Hyper-V, including the following:

  • Greatly improved graphics performance – VMs that are rendering GPU-intensive tasks, such as gaming, video editing, and CAD/CAM programs perform much better with direct access to the GPU
  • Resource consolidation – GPU passthrough can potentially allow consolidating dedicated workstations with discrete graphics hardware and instead run these as virtual machines on a single Hyper-V host
  • VM flexibility – GPU passthrough provides businesses with many of the benefits of virtual machines with the flexibility to run graphics-intensive applications. VMs are much more mobile, scalable, and flexible to run than physical workstations
  • Efficient costs – With GPU passthrough, organizations can passthrough GPUs from the Hyper-V hosts, without having to buy dedicated hardware for each virtual machine or having physical machines running discrete graphics
  • Enhanced Security – GPU passthrough can enhance security by isolating applications that require direct access to the GPU, which reduces the attack surface for potential security threats

Requirements for Hyper-V GPU passthrough

To enable GPU passthrough in Hyper-V, you’ll need to ensure that your hardware and software meet the requirements for GPU virtualization.

Hardware Requirements

  • You need a GPU that supports GPU virtualization, such as NVIDIA GRID or AMD MxGPU technology
  • Your CPU needs to support IOMMU (Input-Output Memory Management Unit) virtualization, which is required for GPU passthrough

Software Requirements

  • Windows Server 2016 or later, or Windows 10 with Hyper-V enabled
  • The Hyper-V role enabled
  • You will want to update to the latest graphics drivers for the Hyper-V host and guest virtual machines

Overview of Enabling Hyper-V GPU passthrough

Once you’ve met the hardware and software requirements, you can enable GPU passthrough in Hyper-V by following these steps:

  • Install the latest graphics drivers for both the host and virtual machine
  • Configure the virtual machine to use RemoteFX for GPU virtualization
  • Assign the GPU device to the virtual machine
  • Install the RemoteFX 3D Video Adapter driver on the virtual machine
  • Configure the virtual machine to use the RemoteFX 3D Video Adapter

Unsupported configurations and limitations to note

There are some unsupported configurations that won’t work with Hyper-V GPU passthrough:

  • GPU passthrough is not supported for virtual machines that use Dynamic Memory, which allows the virtual machine to allocate and deallocate memory as needed
  • GPU passthrough is only available on specific editions of Windows Server, such as the Datacenter edition

Challenges of GPU Passthrough in Hyper-V

While GPU passthrough in Hyper-V offers many benefits, there are also some challenges to consider, such as:

  • Hardware and Software Compatibility: GPU passthrough requires specific hardware and software configurations, which can limit its availability for some businesses
  • Configuration Complexity: Configuring GPU passthrough in Hyper-V can be complex, requiring specialized knowledge and expertise
  • Resource Allocation: Assigning GPU resources to virtual machines can be challenging, as the host must ensure that there is sufficient GPU capacity to support all virtual machines
  • Scalability: GPU passthrough may not scale well in large virtualized environments, where multiple virtual machines require access to the GPU

Configuring GPU Passthrough in Hyper-V

steps for setting up GPU passthrough in Hyper-V

1. Set Memory Limits for GPU Access

set memory limits for the virtual machine (VM) before passing through GPU. Use the following PowerShell commands:

To set everything in one command:

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

Or break it into smaller steps:

  • Set-VM -GuestControlledCacheTypes $True -VMName VMName
    Set-VM -LowMemoryMappedIoSpace 3Gb -VMName VMName
    Set-VM -HighMemoryMappedIoSpace 33280Mb -VMName VMName

These values allocate memory for the GPU to work with the VM. Adjust these settings if the VM doesnt start

2. Find the GPU’s Location Path

GPU’s “location path” is madatory to assign it to the VM. Here’s how to find it:

Using Device Manager:

  1. Open Device Manager (devmgmt.msc)
  2. Find your GPU under Display Adapters
  3. Right-click it, select Properties, go to the Details tab, and choose Location paths. Copy the value

Using PowerShell: Run this command to list GPUs and their location paths:

  • Get-PnpDevice -Class Display | ForEach-Object { Write-Output “$($_.FriendlyName) is at $($_ | Get-PnpDeviceProperty DEVPKEY_Device_LocationPaths | Select-Object -ExpandProperty Data | Where-Object { $_ -like ‘PCIROOT*’ })”; }

Example output:

  • PCIROOT(0)#PCI(0300)#PCI(0000)

3. Prepare the GPU for Passthrough

Disable the GPU on the Hyper-V host:
Open Device Manager, right-click the GPU under Display Adapters, and choose Disable device.
Dismount the GPU:
Use this PowerShell command:

  • Dismount-VmHostAssignableDevice -LocationPath “PCIROOT(0)#PCI(0300)#PCI(0000)” -Force
  • Replace the location path with the one you found earlier

4. Assign the GPU to the VM

Now assign the GPU to the VM using PowerShell:

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

5. Install Drivers in the VM

  1. Start the VM
  2. Open the VM’s Device Manager and check if the GPU appears along with the default Microsoft Hyper-V video adapter
  3. Download and install GPU drivers (from NVIDIA or AMD’s website) inside the VM

6. Reassign or Disconnect the GPU

  • To remove the GPU from the VM:
    Stop the VM and run:
  • Remove-VMAssignableDevice -VMName VMName -LocationPath
    “PCIROOT(0)#PCI(0300)#PCI(0000)”
  • To reassign the GPU to the Hyper-V host:
    Run this command:
  • Mount-VMHostAssignableDevice -LocationPath “PCIROOT(0)#PCI(0300)#PCI(0000)”

This process ensures the GPU is passed through to the VM, allowing it to use the full capabilities of the physical GPU. Let me know if you need further clarifications!

Hyper-V GPU passthrough FAQs

What is Hyper-V GPU passthrough?

Hyper-V GPU passthrough allows virtual machines to access the host’s GPU directly. By using it, virtual machines can achieve drastically better performance for graphics-intensive applications that require dedicated hardware. Use cases including gaming, CAD/CAM, video editing, and others.

What is required for Hyper-V GPU passthrough to work?

You need a GPU that supports GPU virtualization, such as an NVIDIA or AMD GPU that supports NVIDIA GRID or AMD MxGPU technology. Your CPU needs to support IOMMU (Input-Output Memory Management Unit) virtualization. Software requirements include Windows Server 2016 or later, or Windows 10 with Hyper-V enabled, the Hyper-V role enabled, and the latest graphics drivers for the host and the virtual machine.

What limitations do you need to note with Hyper-V GPU passthrough?

GPU passthrough is not supported for virtual machines that use Dynamic Memory, which allows the virtual machine to allocate and deallocate memory as needed. GPU passthrough is only available on certain editions of Windows Server, such as the Datacenter edition.

Wrapping up

Hyper-V GPU passthrough is a great feature found in Hyper-V allowing Hyper-V admins to solve the problem of providing powerful graphics processing in Hyper-V virtual machines. It is especially important in VDI environments where power users may need to remote in and access video editing software, CAD, machine learning, or other applications requiring discrete graphics processing power. With machine learning applications exploding, discrete graphics is required to provide the processing power needed for these types of applications.

Read More:

5 Best Practices to Improve the performance of Hyper-V virtual machines
Hyper-V Mastery: A Step-by-Step Guide for Beginners to Elevate Your IT Skills and Boost Your Career
Beginners’ Guide for Microsoft Hyper-V: How to Troubleshoot Hyper-V VM with No IP address – Part 60

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

1.9/5 - (45 votes)