Share GPU in Hyper-V virtual machine with Windows 11 Tutorial

This is a simple step-by-step tutorial on how to share your physical GPU with your virtual machine running Windows 11. I assume you have some basic knowledge of what a virtual machine and a virtual hard drive are.

This tutorial really works. It’s tested and my virtual computer with Windows 11 Pro is using NVIDIA RTX3060.

To check your system files, open PowerShell in your virtual machine as an administrator and execute the following command:

sfc /scannow

SFC stands for System File Checker. This tool scans all protected system files on your virtual computer and replaces any corrupted files. Running this command is a preventative measure to ensure your system integrity is maintained.

How to share graphic card

  1. Shut down your virtual machine.
  2. Disable snapshots/checkpoints in the settings of your virtual machine.
  3. Mount the virtual drive of your virtual machine in the host computer.

    If you encounter issues when mounting the virtual drive because it is encrypted, go to Disk Management, create a new virtual drive with a name such as SharedVirtualDrive, initialise the disk, create a new simple volume, format it, and then open it. Create a temporary folder, for example, GPU, where you can prepare files for copying into your virtual machine.

  4. Go to C:\Windows\System32\DriverStore on your host computer.
  5. Copy the folder FileRepository to your virtual machine at C:\Windows\System32, where you will create a new folder called HostDriverStore. (or to folder GPU at SharedVirtualDrive)
  6. If you have an Nvidia GPU, there is one more step: copy all the files starting with nv* from C:\Windows\System32 on your host computer and paste them into the same location on your virtual machine, C:\Windows\System32 (or to folder GPU at SharedVirtualDrive).
  7. If you were able to mount the virtual drive, eject it.

If you had to use the new virtual drive SharedVirtualDrive for copying the files, go to the virtual machine settings and attach this drive, start the virtual machine (if you will get error that virtual drive is used by another process, simply restart the host computer), copy the folder and files to the virtual system folder as described above. Once done, shut down the virtual machine.

  1. Open PowerShell ISE on the host computer and paste the following (replace “The Name of your VM”):
$vm = "The Name of your VM"
if (Get-VMGpuPartitionAdapter -VMName $vm -ErrorAction SilentlyContinue) {
Remove-VMGpuPartitionAdapter -VMName $vm
}
Set-VM -GuestControlledCacheTypes $true -VMName $vm
Set-VM -LowMemoryMappedIoSpace 1Gb -VMName $vm
Set-VM -HighMemoryMappedIoSpace 32Gb -VMName $vm
Add-VMGpuPartitionAdapter -VMName $vm

Then execute the script (press Enter).

  1. Start your virtual machine, open Device Manager, and you should see your GPU being shared under Display adapters.
  2. If you update your GPU drivers to the newest version on your host computer and want to apply them to your virtual machine, you will need to repeat the entire process described above.
  3. You can enable Checkpoints again. Create new folder Checkpoints inside folder where are the virtual machine files. Open Settings of your virtual machine and browse “Checkpoint file location”, select folder Checkpoints. Click apply.

Extra recommendations

  1. Always make a backup, including a backup of your virtual machine. Simply copy your virtual machine’s files, ideally to a second physical drive.
  2. Have at least 32GB RAM, so you can assign to the virtual machine 16GB RAM.
  3. Use second NVMe drive, where are stored virtual machine files.
  4. If you want to clone your virtual machine in Hyper-V, export it and then import it. During the import process, choose “Copy the virtual machine (create a new unique ID)”. Remember, the cloned VM will have the same SID as the original, so you may need to use the Sysprep tool to reset the SID if necessary.What is SID? A Security Identifier (SID) is a unique value used to identify a user, group, or computer account in Windows operating systems. SIDs are fundamental to the security architecture of Windows, as they are used to control access to resources and to track user activities. Each account is issued a unique SID when it is created, and this SID is used to manage permissions and access rights.

For what are good checkpoits in Hyper-V?

Checkpoints in Hyper-V are incredibly useful for saving the state of a virtual machine at a specific point in time. Here are the two main types of checkpoints you can use:

  1. Standard Checkpoints: These capture the state, data, and hardware configuration of a running virtual machine. They are ideal for development and testing scenarios where you might need to recreate a specific state or condition of a VM to troubleshoot a problem.
  2. Production Checkpoints: These are designed for production environments and create a data-consistent backup of the VM using backup technology inside the guest OS. They do not capture the VM’s memory state, making them more suitable for production workloads.

You can choose between these types based on your needs. For example, if you’re making software configuration changes or applying updates, creating a checkpoint beforehand can save you a lot of trouble if something goes wrong.