A collection of PowerShell automation tools designed to manage GPU Partitioning (GPU-PV) for Hyper-V Virtual Machines.
Unlike traditional GPU Passthrough (DDA), GPU Partitioning paravirtualizes the host's physical GPU, allowing both the Host OS and the Guest OS to share graphics resources simultaneously. This toolkit automates the complex hardware configurations required to map Memory-Mapped I/O (MMIO) spaces and attach the virtual GPU adapters.
Manage-VMGpuPartition.ps1: Safely enables or disables GPU-PV on a target Virtual Machine.- Dynamically allocates High/Low MMIO space.
- Configures Guest-Controlled Cache Types.
- Fully reversible (restores standard Hyper-V 512MB default memory allocations).
- Validates Administrator privileges and VM state to prevent hypervisor crashes.
-
Copy-HostGpuDriver.ps1: Mount the VM's VHDX and automatically mirror the host's AMD/Nvidia drivers into the Guest'sHostDriverStoredirectory. -
New-VMGpuCheckpoint.ps1: Automate standard Hyper-V checkpoints by temporarily detaching the GPU, snapshotting the VM, and reattaching it (bypassing Hyper-V's hardware-lock limitations).
- Windows 10/11 Pro, Enterprise, or Education (with Hyper-V enabled).
- PowerShell 5.1 or PowerShell 7+ running as Administrator.
- The target Virtual Machine must be turned OFF before modifying hardware settings.
- The target Virtual Machine must have the checkpoints disabled.
Until the automated driver injection script is developed, you must manually mirror the Host GPU drivers into the Guest OS. Without this, the Guest OS will see the GPU but will be unable to initialize it (Error Code 43).
- On your Host Machine, navigate to:
[Windows Drive]:\Windows\System32\DriverStore\ - Identify the folder that contains multiple
.dllfiles and the.inffile for your current driver version. Usually this folder is called FileRepository. Copy this entire folder to a temporary location (like your Desktop) or just keep it in the clipboard.
- Ensure the Guest VM is completely powered off.
- Locate your VM's hard drive file (usually a
.vhdxfile). - Right-click the
.vhdxand select Mount. It will appear as a new drive letter (e.g.,E:\) in File Explorer.
- Navigate to the following path inside the mounted Guest drive:
[Guest Drive Letter]:\Windows\System32\ - Create a new folder named
HostDriverStore(if it doesn't exist). - Inside
HostDriverStore, paste the previously copied folder namedFileRepository.- Final Path should look like:
[Guest Drive Letter]:\Windows\System32\HostDriverStore\FileRepository
- Final Path should look like:
- If you have an Nvidia Card, copy all the files starting with nv from the Host's
[Windows Drive]:\Windows\System32\and paste them on the same location but in the guest drive.
- Right-click the mounted Guest drive in File Explorer and select Eject.
- Run the
Manage-VMGpuPartition.ps1script to attach the GPU. - Power on the VM. Your GPU should now appear in the Guest's Device Manager under Display Adapters.
Download or clone the repository to your host machine. Open PowerShell as an Administrator and execute the script:
To Enable GPU Partitioning:
.\Manage-VMGpuPartition.ps1 -VMName "YourVMName" -Action EnableTo Disable GPU Partitioning (Revert to Defaults):
.\Manage-VMGpuPartition.ps1 -VMName "YourVMName" -Action DisableTo Specify Custom VRAM / MMIO Allocation: (Useful for high-VRAM cards like RTX4090 or RX 7900 XTX)
.\Manage-VMGpuPartition.ps1 -VMName "YourVMName" -Action Enable -HighMMIO "64Gb"Modifying Hyper-V hardware allocations and MMIO spaces ties your Guest VM to the physical hardware of your Host. This will intentionally break standard Hyper-V features like Live Migration, Saved States, and Checkpoints while the GPU is attached. Use at your own risk.