Which GPU Assignment Method Should You Use for Hyper-V Virtual Machines?

Image showing an open laptop with a brain on the screen.
How will you assign GPUs to your Hyper-V virtual machines?
Source: mohamed_hassan on Pixabay

When server virtualization first gained popularity, graphics processing unit (GPU) assignments were barely a consideration. At the time, relatively few workloads required GPUs—and those that did typically weren’t a good fit for virtualized environments. Today, of course, things are different. Companies use GPUs for graphically intensive workloads and workloads that leverage machine learning (ML) capabilities. As such, being able to allocate GPUs to virtual machines (VMs) is a must. But did you know you can assign GPUs to Hyper-V VMs in two different methods? Each method greatly impacts how you can use the GPU and your company’s security.

In this article, I’ll take you through these two methods. I’ll also explain how each method impacts performance and security. Let’s dive right in!

2 GPU Assignment Methods

As mentioned earlier, Hyper-V provides two different options for assigning GPUs to virtual machines. One option is to use RemoteFX. The other option is to use a discrete device assignment. Unfortunately, neither option is suitable for every situation. So you’ll have to weigh your use case when deciding which method to use. Let’s discuss each method in further detail, starting with RemoteFX.

1. RemoteFX

RemoteFX is essentially an extension of Microsoft’s Remote Display Protocol (RDP). When the technology was first introduced in Windows Server 2008 SP1, it was best known for its ability to redirect USB devices to a virtual machine. Since then, however, RemoteFX has gained many other capabilities—including GPU redirection through a feature known as RemoteFX vGPU.

But not all Windows versions support RemoteFX vGPU. You’ll need a machine running Windows 7 Ultimate or Enterprise, or Windows Server 2008 R2 SP1 or higher to use it. 

It’s also important to note that Windows recently removed RemoteFX vGPU, so you won’t find support for it in Windows 11 or Windows Server 2022. This is because many security vulnerabilities plagued this technology. 

But why would you want to use RemoteFX vGPU if it’s discontinued? The main reason is that it’s well suited to high-VM density environments

Suppose for a moment that a Hyper-V host contains only a single GPU. RemoteFX vGPU allows multiple virtual machines to share that one GPU. This isn’t the case for discrete device assignments. 

But it’s worth noting that RemoteFX vGPU limits each VM to use only 1 GB of dedicated video RAM. Keep this in mind if you decide to go with this method.

Enabling RemoteFX vGPU

If you have a supported operating system (OS) but can’t use RemoteFX vGPU, the support for this technology was most likely removed by an update. But you should still be able to find it in your VM’s device list. Once you do, simply highlight it and click “Add”. 

Screenshot showing the Settings window for a specific virtual machine called VM1.
If your system supports RemoteFX vGPU, the Add Hardware setting for VMs will include a RemoteFX 3D Graphics Adapter option.

2. Discrete Device Assignment

Unlike RemoteFX vGPU, which can share a GPU across multiple VMs, a discrete device assignment dedicates a physical GPU to a single VM

At first, this may seem like a less-than-desirable method for GPU allocation. If you have a high-VM density environment, it wouldn’t be practical to dedicate a single GPU to a single VM. But if this isn’t the case, this method does have its perks.

For instance, when opting for this method, the GPU won’t have the RemoteFX vGPU’s 1 GB limit. And if you’re using the GPU for graphical applications, discrete device assignments will deliver a higher frame rate. RemoteFX vGPU has a limit of 30 frames per second (FPS), while discrete device assignments have a limit of 60 FPS.

I’ll now briefly explain how you can enable discrete device assignments.

Enabling Discrete Device Assignments

To perform a discrete device assignment, you’ll need to know the device’s location path. To find the location path, follow these steps:

  1. Open the Device Manager
  2. Select the device you want to assign
  3. Right-click on the device and select the Properties command from the shortcut menu
  4. Select the properties sheet’s Details tab
  5. Choose the Location Path option from the list of properties
  6. Make note of the value
Screenshot showing the Details tab in the NVIDIA GeForce GTX 970 Properties window.
Make note of the device’s location path.

Once you know the location path, you’ll need to complete the discrete device assignment through PowerShell. Before doing this, create a variable called $LocationPath and set it equal to the device’s location path. Here are the remaining commands you can use in PowerShell to finalize the discrete device assignment, as documented by Microsoft:

Screenshot showing commands needed to complete a discrete device assignment.
Enter these commands to complete the discrete device assignment.

Here are a few things to keep in mind about the above commands:

  • Replace the VMName (don’t confuse this with -VMName) with the name of your virtual machine
  • Power your virtual machine off before performing these actions
  • Confirm the memory mapping in the third and fourth commands matches your GPU’s hardware

And that’s it! Simple, right? Let’s have a quick recap now, shall we?

The Bottom Line

With more and more aspects of your business needing GPUs, you need to know how to give your VMs the GPU they need to function. 

In this article, we discussed two methods for GPU allocation in Hyper-V. For instance, you may opt to use the RemoteFX vGPU in some environments. And this way, you’ll be able to share GPU hardware among multiple VMs. But this option is riddled with security vulnerabilities, so it’s not a great option for security. 

On the other hand, Microsoft recommends using discrete device assignments because they’re more secure. And though they’re more GPU-intensive (with each VM needing a single GPU), they won’t limit your RAM usage and will give you a higher FPS rate. 

And with this in mind, you can choose which GPU allocation method you’ll use based on your specific needs.

Do you have more questions about Hyper-V and GPU assignment methods? Check out the FAQ and Resources sections below!

FAQ

Does Microsoft have a preferred method for GPU redirection in Hyper-V?

Yes, Microsoft’s preferred method is to use discrete device assignments whenever possible. In 2020, Microsoft deprecated RemoteFX vGPU because of a remote code execution vulnerability. As such, Microsoft removed RemoteFX vGPU from newer Windows builds starting in April 2021.

Does Hyper-V impose any hardware limitations concerning the type of GPUs I can use?

Microsoft officially supports “enterprise GPUs” such as NVIDIA Quadro/GRID or AMD FirePro. Unofficially, any PCI-based GPU that works with Windows will typically work but might not be officially supported. Your best option is to review the Microsoft hardware compatibility list.

Should I disable RemoteFX vGPU if I am not using it?

RemoteFX vGPU contains security vulnerabilities. Because of this, Microsoft has discontinued it in many versions of Windows. Disabling it is a good idea overall, and you can do this by installing the latest security patches. Remember that installing these patches will typically remove support for RemoteFX vGPU.

Do the security vulnerabilities associated with RemoteFX vGPU impact any other RemoteFX features?

According to Microsoft, no. The vulnerabilities impact vGPU but don’t impact any other RemoteFX features.

Does using a discrete device assignment cause any issues with failover clustering?

A discrete device assignment is a direct mapping between a physical piece of hardware and a virtual machine. This mapping means that the VM essentially owns that hardware. If you moved the virtual machine to another host, the mapping would break because the new host lacks the assigned hardware. That said, you can’t use discrete device assignments within a failover cluster.

Resources

TechGenix: Article on Hyper-V and Physical GPUs

Learn the basics of enabling physical GPUs in Hyper-V.

TechGenix: Article on GPU Cloud Computing

Read more on what CIOs need to know about GPU cloud computing.

TechGenix: Article on Microsoft Azure ND-Series

Find out how Microsoft Azure ND-series provides GPUs in the cloud.

Microsoft: Article on Deploying Graphics Devices Using RemoteFX

Discover how you can deploy graphics devices using RemoteFX vGPU.

Windows 10 Help Forums: Post on GPU Passthrough

Educate yourself on what GPU passthrough is.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top