Step 23 of 82
← Home
πŸ–₯️ Phase: Infrastructure

Step 23 NVIDIA GPU in Hyper-V VM

Why this step? Enable GPU passthrough for workloads that need graphics hardware.

How do I get NVIDIA GPU support in Hyper-V virtual machine?

Make sure the nvidia drivers are installed on the Hyper-V host. Disable snapshots and shut down the virtual machine. You can then mount the VM disk (just double-click) on the host, which makes the following steps easier.

Step 1: Do not copy nv*.* files or the host DriverStore into the guest. That is not a supported driver-installation method and can break driver integrity and system stability. Use the documented GPU-P partitioning support for the exact Windows host and guest versions, and install matching guest drivers from NVIDIA inside the guest when required.

Step 2: Give virtual machine access to host GPU.

Disable snapshots and shut down the virtual machine. Open powershell in admin mode. Change the name of the VM in the first line to your virtual machine name before copying/pasting this code.

Then copy/paste this code and press enter for the last line:

$vm = "VM11"
if (Get-VMGpuPartitionAdapter -VMName $vm) {Remove-VMGpuPartitionAdapter -VMName $vm}
Set-VM -GuestControlledCacheTypes $true -VMName $vm
Set-VM -LowMemoryMappedIoSpace 1Gb -VMName $vm
Set-VM -HighMemoryMappedIoSpace 16Gb -VMName $vm
Add-VMGpuPartitionAdapter -VMName $vm

Result: image