Tutorial: Passing Multiple GPUs to a Hyper-V Virtual Machine
In this tutorial, we will walk you through the process of passing multiple NVIDIA 1080 Ti GPUs to a Hyper-V virtual machine. This can be useful for a variety of reasons, such as running GPU-intensive workloads, virtualizing graphics applications, or creating a setup for machine learning and deep learning.
Prerequisites
Before starting this tutorial, make sure you have the following:
- A host system with at least two NVIDIA 1080 Ti GPUs installed.
- The Hyper-V role enabled on the host system.
- The latest NVIDIA graphics drivers installed on the host system.
- The NVIDIA Grid software installed on the host system (available through a Grid license, or as a free download for limited functionality).
Setting up the Virtual Machine
To start, create a new virtual machine in Hyper-V. When configuring the hardware, make sure to allocate at least one processor core to the virtual machine. For the graphics settings, choose "GPU Passthrough" and select the first NVIDIA 1080 Ti GPU from the list.
Once the virtual machine is created, install a supported version of Windows or Linux on it. After installation, make sure that the NVIDIA drivers are installed properly within the guest operating system.
Adding the Second GPU
To pass the second GPU to the virtual machine, you will need to edit the virtual machine's settings. In the hardware configuration, add a second "Synthetic PCi-E Device" and choose "VGA (Standard VGA Graphics Adapter)" as the device type. This will allow the virtual machine to recognize the second GPU.
Now, you will need to edit the virtual machine's registry settings. Open the registry editor (regedit) on the host system and navigate to the following key:
HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\00XXReplace "00XX" with the instance number of the first NVIDIA GPU passed to the virtual machine. In this example, if the first GPU was instance 0000, the registry key would be:
HKEY\_LOCAL\_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000Now, create a new key named "00YY" (where "00YY" is the instance number of the second GPU). In this new key, create a new DWORD value named "ParentIdPrefix" and set its value to the instance number of the first GPU (in this example, 0000).
Configuring the Guest Operating System
Once the second GPU has been passed to the virtual machine, you will need to configure the guest operating system to use it. In Linux, this can be done by using the "nvidia-xconfig" tool to create a new X.org configuration file. In Windows, you will need to install the NVIDIA drivers for the second GPU and configure it through the NVIDIA control panel.
Performance Considerations
When running multiple GPUs in a virtual machine, it is important to consider the performance implications. Sharing a single host system with multiple GPUs can lead to decreased performance due to resource contention. Make sure to monitor the performance of the virtual machine and make adjustments as necessary.
- Enable the Hyper-V role and install NVIDIA drivers on the host system.
- Create a virtual machine and pass the first GPU through.
- Edit the registry to pass the second GPU through.
- Configure the guest operating system to use the second GPU.
- Monitor and optimize performance as needed.