Skip to content

Humminity/HyperV-GPUv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Hyper-V GPU-PV Toolkit

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.

Features

Current

  • 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.

Future Roadmap

  • Copy-HostGpuDriver.ps1: Mount the VM's VHDX and automatically mirror the host's AMD/Nvidia drivers into the Guest's HostDriverStore directory.
  • 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).

Prerequisites

  • 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.

Manual Driver Setup Guide

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).

Step 1: Locate the Driver on the Host

  1. On your Host Machine, navigate to:
    [Windows Drive]:\Windows\System32\DriverStore\
  2. Identify the folder that contains multiple .dll files and the .inf file 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.

Step 2: Mount the Guest VM Disk

  1. Ensure the Guest VM is completely powered off.
  2. Locate your VM's hard drive file (usually a .vhdx file).
  3. Right-click the .vhdx and select Mount. It will appear as a new drive letter (e.g., E:\) in File Explorer.

Step 3: Mirror the Drivers to the Guest

  1. Navigate to the following path inside the mounted Guest drive:
    [Guest Drive Letter]:\Windows\System32\
  2. Create a new folder named HostDriverStore (if it doesn't exist).
  3. Inside HostDriverStore, paste the previously copied folder named FileRepository.
    • Final Path should look like: [Guest Drive Letter]:\Windows\System32\HostDriverStore\FileRepository
  4. 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.

Step 4: Cleanup and Run

  1. Right-click the mounted Guest drive in File Explorer and select Eject.
  2. Run the Manage-VMGpuPartition.ps1 script to attach the GPU.
  3. Power on the VM. Your GPU should now appear in the Guest's Device Manager under Display Adapters.

Usage

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 Enable

To Disable GPU Partitioning (Revert to Defaults):

.\Manage-VMGpuPartition.ps1 -VMName "YourVMName" -Action Disable

To 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"

Disclaimer

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.

About

PowerShell automation tools for managing Hyper-V GPU Partitioning (GPU-PV)

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors