Interactive PowerShell script to configure GPU Partitioning (GPU-P) on a Hyper-V Windows guest VM and copy GPU drivers from the host into the VM disk.
Supports AMD and NVIDIA.
- Prompts for GPU vendor (AMD or NVIDIA).
- Lists Hyper-V VMs and prompts for selection.
- Shuts down the VM if it is running.
- Configures the GPU-P adapter and mapped memory settings.
- Mounts the VM disk on the host.
- Copies vendor driver packages from the host
DriverStoreto the guestHostDriverStore. - Dismounts the disk and starts the VM.
- Windows with Hyper-V enabled
- PowerShell run as Administrator
- GPU with GPU-P support on the host
- Vendor drivers installed on the host (
C:\Windows\System32\DriverStore\FileRepository) - An existing Windows guest VM in Hyper-V
Open PowerShell as Administrator and run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\setup-gpup.ps1Follow the prompts to select vendor and VM.
GPU Vendor:
[1] AMD
[2] NVIDIA
Select vendor: 1
Virtual Machines:
[1] MyVM [Off]
Select VM: 1
Selected: MyVM (AMD)
Finding guest disk...
Guest disk: D:\Hyper-V\MyVM\Virtual Hard Disks\disk.vhdx
Configuring GPU-P...
Mounting guest disk...
Guest Windows: E:
Copying 3 AMD driver packages...
...
Dismounting guest disk...
Starting VM...
GPU-P setup completed successfully.
MyVM is running.
| Setting | Value |
|---|---|
| GPU partition adapter | Added (replaces existing adapter if present) |
| GuestControlledCacheTypes | $true |
| LowMemoryMappedIoSpace | 1 GB |
| HighMemoryMappedIoSpace | 32 GB |
| Automatic checkpoints | Disabled |
Host DriverStore folders are copied to:
<guest-drive>:\Windows\System32\HostDriverStore\FileRepository
| Vendor | Folder name filter |
|---|---|
| AMD | amd, ati, radeon |
| NVIDIA | nvidia, nv_disp, nv_dispi, nvhda, nvlt |
Install the correct GPU drivers on the host before running the script.
- If setup fails, the VM is not started.
- The VM disk is dismounted in the
finallyblock, even on error. - If the disk is still mounted after setup, the script exits before starting the VM.
- Windows guest VMs only.
- Uses the first valid virtual disk on the VM (sorted by controller).
- The VM must be off while drivers are copied.
- NVIDIA GPU-P may require additional host setup (vGPU stack) beyond driver copy.
- Checkpoints are not supported on VMs with a GPU partition adapter. The script disables automatic checkpoints during setup.
| Error | Likely cause |
|---|---|
No virtual machines found |
No VMs in Hyper-V |
No valid virtual hard disk found |
VM has no valid VHD/VHDX |
Windows partition not found |
No drive letter on the Windows partition after mount |
No AMD/NVIDIA driver packages found on the host |
Drivers not installed on the host |
Failed to dismount guest disk |
Disk still in use; close programs accessing the VHD |
Failed to start VM |
GPU-P not supported or configuration incomplete |
Checkpoint operation failed / Checkpoints have been disabled |
GPU-P VMs cannot use checkpoints; re-run the script or run Set-VM -Name <vm> -AutomaticCheckpointsEnabled $false |
- Run only on VMs you own and control.
- Back up the VHD/VHDX before the first run.
- The script force-stops the VM if it is running.