A comprehensive PowerShell tool for GPU partitioning (GPU-PV) in Hyper-V virtual machines. Simplifies the process of sharing your GPU with VMs for gaming, development, machine learning, and other GPU-accelerated workloads.
- Automated VM Creation with presets for common use cases
- GPU Partitioning - Allocate GPU resources (1-100%) to VMs
- Driver Injection - Automatically inject host GPU drivers into VM disks
- Automated Windows Installation - Create unattended installation ISOs
- VM Management - View, configure, and delete VMs with GPU assignments
- Error Handling - Comprehensive error messages with pauses for readability
- PowerShell 5.1 Compatible - Works on Windows 10/11 without PowerShell 7
- Windows 10/11 Pro, Enterprise, or Education
- Hyper-V enabled (will not work on Home editions)
- Administrator privileges (script auto-elevates)
- Partitionable GPU with drivers installed on host
- Most modern NVIDIA, AMD, and Intel GPUs support GPU-PV
- Check GPU compatibility with Menu Option 6: "GPU Info"
- Windows ADK (Assessment and Deployment Kit) for automated installation ISO creation
- Download: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install
- Only required if you want to use the automated installation feature
- If not installed, autounattend.xml will be saved to Desktop for manual use
- Download
GPU-PV-Manager.ps1 - Right-click → Run with PowerShell
- Script will auto-elevate to Administrator if needed
Alternative: Run from PowerShell:
powershell.exe -ExecutionPolicy Bypass -File "GPU-PV-Manager.ps1"- UP/DOWN arrows - Navigate menu items
- ENTER - Select option
- ESC - Cancel/Go back
- Press Enter prompts - Continue after operations complete
Creates Generation 2 VMs optimized for GPU partitioning.
VM Presets:
| Preset | CPU Cores | RAM | Storage | Use Case |
|---|---|---|---|---|
| Gaming | 8 | 16GB | 256GB | Gaming, high-performance apps |
| Development | 4 | 8GB | 128GB | Development, testing |
| ML Training | 12 | 32GB | 512GB | Machine learning, AI workloads |
| Custom | User-defined | User-defined | User-defined | Fully customizable |
VM Configuration:
- Generation 2 (UEFI-based)
- Secure Boot enabled (On by default)
- TPM 2.0 enabled with local key protector
- Static memory allocation (no dynamic memory)
- Checkpoints disabled for performance
- Custom automatic start/stop actions configured
- Boot order: DVD → Hard Disk (for installation)
Automated Installation (Optional): When providing an ISO path, you can enable automated Windows installation:
- Creates modified ISO with
autounattend.xmlinjected - Automatic disk partitioning - Creates UEFI partitions (WINRE, EFI, MSR, Windows)
- Skips setup screens - Bypasses EULA, privacy settings, etc
- User interaction required:
- Windows edition selection during installation
- User account creation after first boot
- Requires Windows ADK for ISO creation (oscdimg.exe)
- Fallback: If ADK not installed, autounattend.xml saved to Desktop
File Locations:
- VHDs:
C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\ - Auto-install ISOs:
C:\ProgramData\HyperV-ISOs\
Allocates GPU resources to a virtual machine.
Process:
- Select target VM from list (shows current state and specs)
- Choose partitionable GPU from host
- Specify GPU allocation percentage (1-100%)
- VM automatically stops if running (graceful shutdown with 60s timeout)
- Configures GPU partition adapter with resource limits:
- VRAM (Video RAM)
- Encode (Video encoding)
- Decode (Video decoding)
- Compute (GPU compute/CUDA/OpenCL)
- Sets memory-mapped I/O:
- Low MMIO: 1GB
- High MMIO: 32GB
- Enables guest-controlled cache types
Requirements:
- VM must be stopped (script handles this automatically)
- GPU must support partitioning (check with GPU Info menu)
Notes:
- Allocation percentage applies to all resource types equally
- Removing GPU partition also cleans up MMIO settings
- Can reallocate different percentage by running again
Removes GPU partition and cleans all driver files from VM disk.
Process:
- Confirms GPU partition exists on selected VM
- Prompts for confirmation
- Stops VM if running (graceful shutdown)
- Removes GPU partition adapter
- Resets memory-mapped I/O settings:
- Low MMIO: 0
- High MMIO: 0
- Guest-controlled cache: Disabled
- Mounts VM disk to
C:\ProgramData\HyperV-Mounts\VMMount_<random> - Cleans driver files:
- Deletes entire
Windows\System32\HostDriverStoredirectory - Removes individual driver files from System32 and SysWow64
- Reports files/folders removed
- Deletes entire
- Unmounts disk and cleans up mount point
Error Handling:
- VM without Windows installed: Gracefully handles mount failures
- GPU adapter and MMIO settings still removed
- Displays "GPU REMOVAL PARTIAL" message
- Informs user driver cleanup was skipped
- All errors pause for user to read before returning to menu
Injects host GPU drivers into VM disk automatically.
Requirements:
- GPU partition must be assigned first (enforced by script)
- Windows must be installed in the VM
- VM must have VHDX attached
- VM will be stopped automatically if running
Detection Process:
- Identifies GPU from partition adapter (matches VEN/DEV IDs)
- Queries WMI for GPU info (Win32_VideoController)
- Searches registry:
HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968...} - Locates GPU's INF file in
C:\Windows\INF\ - Parses INF for driver file references:
.sys,.dll,.exe,.cat,.inf,.bin,.vp,.cpa
- Searches for files in:
C:\Windows\System32\DriverStore\FileRepository(recursive)C:\Windows\System32(non-recursive)C:\Windows\SysWow64(non-recursive)
Copy Process:
- Mounts VM disk to
C:\ProgramData\HyperV-Mounts\VMMount_<random> - Creates
Windows\System32\HostDriverStore\FileRepositoryin VM - Copies driver folders with all contents (preserves structure)
- Copies system files to matching paths (System32/SysWow64)
- Reports total files and folders injected
- Unmounts disk and cleans up
Error Messages:
- No GPU partition assigned: Directs user to assign GPU first
- GPU driver not found on host: Ensure GPU drivers installed on host
- No VHD found: VM may not have disk attached
- Windows not installed: Clear error with pause before returning to menu
Success Output:
DRIVER INJECTION COMPLETE
Injected 156 files + 3 folders
Displays comprehensive overview of all Hyper-V VMs.
Information Shown:
| Column | Description | Example |
|---|---|---|
| Icon | State indicator | [*] Running, [ ] Off, [~] Other |
| VM Name | Virtual machine name | Dev-VM, Gaming-VM |
| State | Current state | Running, Off, Saved, Paused |
| CPU | Processor count | 4, 8, 12 |
| RAM(GB) | Memory allocation | 8, 16, 32 |
| Storage | VHDX size in GB | 128, 256, 512 |
| GPU | GPU model and allocation | RTX 4090 (50%), None |
Color Coding:
- Green: Running VMs
- Gray: Stopped VMs
- Yellow: Other states (Saved, Paused, etc.)
GPU Detection:
- Shows friendly GPU name (e.g., "NVIDIA GeForce RTX 4090")
- Displays allocation percentage
- Shows "None" if no GPU assigned
Example Output:
+----------------------------------------------------------------------------------------+
| | VM Name | State | CPU | RAM(GB) | Storage | GPU |
+----------------------------------------------------------------------------------------+
| [*] Gaming-VM | Running | 8 | 16 | 256 | RTX 4090 (75%) |
| [ ] Dev-VM | Off | 4 | 8 | 128 | RTX 4090 (25%) |
| [ ] Test-VM | Off | 4 | 8 | 64 | None |
+----------------------------------------------------------------------------------------+
Displays all physical GPUs with detailed information and partitioning capability.
Information Shown:
| Column | Description |
|---|---|
| # | GPU index number |
| Status | [OK] Working, [X] Error/Issue |
| GPU Name | Full device name (e.g., "NVIDIA GeForce RTX 4090") |
| Driver Version | Current driver version |
| Provider | Driver provider (NVIDIA, AMD, Intel) |
| Partitionable | Yes (Cyan) or No (Gray) |
Detection:
- Queries WMI
Win32_VideoController - Excludes Microsoft/Remote Display adapters
- Matches VEN/DEV IDs against
Get-VMHostPartitionableGpuoutput - Correctly identifies NVIDIA, AMD, and Intel GPUs
Partitionability Check:
- Compares GPU hardware IDs with Hyper-V partitionable GPU list
- Only GPUs marked "Yes" can be used for GPU partitioning
Example Output:
+-------------------------------------------------------------------------------------------+
| # | Status | GPU Name | Driver Version | Provider | Partitionable |
+-------------------------------------------------------------------------------------------+
| 1 | [OK] | NVIDIA GeForce RTX 4090 | 31.0.15.5123 | NVIDIA | Yes |
| 2 | [OK] | Intel UHD Graphics 770 | 31.0.101.4146 | Intel | No |
+-------------------------------------------------------------------------------------------+
Completely removes a virtual machine with optional file cleanup.
Process:
- Select VM to delete
- Displays VM information:
- VM name and current state
- VHD path (if exists)
- Auto-install ISO path (if from this script)
- External ISO path (if manually attached, will not be deleted)
- Confirms deletion with user
- Asks whether to delete associated files (VHD and auto-install ISO)
- Stops VM if running (graceful shutdown)
- Removes GPU partition if exists
- Deletes VM from Hyper-V
- Optionally deletes files:
- VHDX file (if user confirmed)
- Auto-install ISO (only if created by this script)
- External ISOs are never deleted (preserved)
File Handling:
- VHD always shown if attached to VM
- Auto-install ISOs (in
C:\ProgramData\HyperV-ISOs\) offered for deletion - External ISOs logged but never deleted
- User chooses whether to delete files or preserve them
Success Output:
VM DELETED SUCCESSFULLY
VM 'Dev-VM' has been removed
Associated files deleted
Or if files preserved:
VM DELETED SUCCESSFULLY
VM 'Dev-VM' has been removed
VHD preserved: C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\Dev-VM.vhdx
ISO preserved: C:\ProgramData\HyperV-ISOs\Dev-VM-AutoInstall.iso
1. Menu → Create VM
- Select "Gaming" preset
- Enter VM name (or press Enter for default "Gaming-VM")
- Enter Windows ISO path: C:\ISOs\Win11.iso
- Choose "Y" for automated installation
2. Wait for ISO creation (automated installation ISO)
- Script creates modified ISO with autounattend.xml
- VM created and ISO attached
3. Start VM in Hyper-V Manager
- Windows installation proceeds automatically
- Select Windows edition when prompted
- Create user account after first boot
4. After Windows installation completes, shut down VM
5. Menu → GPU Partition
- Select your VM
- Choose GPU (e.g., RTX 4090)
- Allocate 50% (or desired percentage)
6. Menu → Install Drivers
- Select your VM
- Script injects GPU drivers automatically
7. Start VM
- GPU appears in Device Manager
- Ready for gaming/GPU workloads!
1. Update GPU drivers on host system (download from manufacturer)
2. Run GPU-PV-Manager.ps1
3. Menu → Install Drivers
- Select first VM
- Wait for injection to complete
- Press Enter
4. Repeat for each VM with GPU partition
5. Restart all VMs to load new drivers
1. Menu → Unassign GPU
- Select VM currently using GPU
- Confirm removal
- Driver files cleaned automatically
2. Menu → GPU Partition
- Select different VM
- Choose same GPU
- Allocate desired percentage
3. Menu → Install Drivers
- Select the new VM
- Drivers injected
4. Start new VM - GPU now available
1. Menu → GPU Partition
- Select first VM
- Choose GPU
- Allocate 50%
2. Menu → Install Drivers
- Select first VM
3. Menu → GPU Partition
- Select second VM
- Choose same GPU
- Allocate 50% (total 100% allocated)
4. Menu → Install Drivers
- Select second VM
5. Both VMs can now use the GPU
- VHD Storage:
C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\ - ISO Storage:
C:\ProgramData\HyperV-ISOs\(automated installation ISOs) - Temporary Mounts:
C:\ProgramData\HyperV-Mounts\VMMount_<random> - GPU Registry:
HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}
The script creates a modified Windows installation ISO with autounattend.xml that:
- Partitioning: Creates UEFI GPT layout (WINRE, EFI, MSR, Windows partitions)
- Automation: Accepts EULA, disables privacy prompts, etc
- Locale: en-US (configurable by editing XML)
- User Interaction: Edition selection and account creation still required
- Boot Prompt: Uses
efisys_noprompt.binif available to skip boot menu
Requirements:
- Windows ADK installed (specifically oscdimg.exe)
- Source ISO must be Windows 10/11 installation media
Fallback:
- If ADK not found, autounattend.xml is copied to Desktop
- User can manually copy it to installation media root
All created VMs are configured with:
- Generation: 2 (UEFI-based, required for GPU-PV)
- Firmware:
- Secure Boot: On (SecureBootTemplate: "MicrosoftUEFICertificateAuthority")
- TPM: Enabled with new local key protector
- Memory:
- Static allocation (DynamicMemoryEnabled: $false)
- Startup memory set to specified GB
- Processor:
- Count set to specified cores
- Storage:
- VHDX format (dynamic expansion)
- SCSI controller
- Checkpoints:
- Type: Disabled
- Automatic checkpoints: Disabled
- Automatic Actions:
- Start: Nothing (manual start)
- Stop: ShutDown (graceful)
When selecting VMs, the interface displays:
- State Icons:
[*]Running VM (green)[ ]Stopped VM (gray)[~]VM in other state (yellow) - Saved, Paused, etc.
- VM Details:
- Name (padded to 20 characters)
- State with brackets
- CPU core count
- RAM in GB
- GPU allocation percentage or "None"
- All errors pause before returning to menu (user must press Enter)
- Descriptive error messages with suggested actions
- Graceful handling of missing Windows installations
- Partial success reporting when some operations succeed
- Timeout handling for VM shutdown (60 seconds)
- Forced shutdown fallback if graceful shutdown times out
- Administrator elevation: Auto-prompts if not running as admin
- Secure mount points: ACL protection (SYSTEM and Administrators only)
- TPM & Secure Boot: Enabled on all created VMs
- Execution policy bypass: Only for script execution, doesn't change system policy
The script uses multiple methods to identify GPU drivers:
- Registry analysis: Searches GPU class registry for matching device IDs
- INF parsing: Extracts file references from driver INF files
- File location: Searches multiple paths (DriverStore, System32, SysWow64)
- VEN/DEV matching: Matches partition adapter to host GPU by hardware IDs
GPU partitioning requires MMIO space for GPU communication:
- Low MMIO: 1GB (below 4GB address space)
- High MMIO: 32GB (above 4GB address space)
- Guest Cache Control: Enabled (allows VM to manage GPU cache)
These settings are:
- Applied when assigning GPU partition
- Reset to 0 when removing GPU partition
- Required for proper GPU function in VM
Edit lines 767-770 in the script to add/modify presets:
$script:VMPresets = @(
@{Label="Your Custom | 16CPU, 64GB, 1TB"; Name="Custom-VM"; CPU=16; RAM=64; Storage=1024},
# ... existing presets
)Modify the New-AutoUnattendXML function (lines 28-125) to customize:
- Language/locale settings
- Time zone
- Product key
- Computer name
- Partition layout
Call functions directly from PowerShell:
# Source the script
. .\GPU-PV-Manager.ps1
# Create VM
$config = @{
Name = "My-VM"
CPU = 8
RAM = 16
Storage = 256
Path = "C:\ProgramData\Microsoft\Windows\Virtual Hard Disks\"
ISO = "C:\ISOs\Win11.iso"
}
New-GpuVM -Config $config
# Assign GPU (50% allocation)
Set-GPUPartition -VMName "My-VM" -Pct 50 -GPUPath "<GPU-Instance-Path>" -GPUName "RTX 4090"
# Install drivers
Install-GPUDrivers -VMName "My-VM"Process multiple VMs:
# Update drivers on all VMs with GPU partitions
Get-VM | Where-Object { Get-VMGpuPartitionAdapter $_.Name -EA SilentlyContinue } | ForEach-Object {
Write-Host "Updating drivers for $($_.Name)"
Install-GPUDrivers -VMName $_.Name
}GPU-PV-Manager is provided as-is under the MIT License.
Free for personal, educational, and commercial use. No warranty provided.
Note: This is a community tool. Support is best-effort and not guaranteed.