Skip to content

Instantly share code, notes, and snippets.

@ThioJoe
Created January 5, 2024 19:39
Show Gist options
  • Save ThioJoe/56e1c4951be2c1a19b126ec619ec26c4 to your computer and use it in GitHub Desktop.
Save ThioJoe/56e1c4951be2c1a19b126ec619ec26c4 to your computer and use it in GitHub Desktop.
PowerShell script to allocate and pass through GPU to Hyper-V Virtual Machine
# Script to easily set resource allocation for GPUs to be passed through into a Hyper-V VM
#
# Author: ThioJoe / https://github.com/thiojoe
#
### Instructions for copying drivers to VM - Will likely need to do this before running this script
# NOTE: Instead of manually copying the files, if you have an Nvidia GPU you can use my other script called "Copy-GPU-Drivers-VM.ps1" to do it automatically
# 1. Open C:\Windows\System32 on host machine and copy any files beginning with "nv" (Except nvspinfo.exe and NvAgent.dll , which are unrelated)
# 2. Place those files into the System32 folder on the VM
# 3. On the VM, create the following directory: C:\Windows\System32\HostDriverStore\FileRepository
# 4. For Nvidia GPUs, open C:\Windows\System32\DriverStore\FileRepository, copy any folders beginning with "nv_" (The number of folders should match the number of GPUs, or at least number of different models of GPU)
# 5. Place those copied folders into the new HostDriverStore\FileRepository folder on the VM
# 6. Shut down VM and run this script.
# Ask for user input for VM Name
do {
Write-Host ""
$vm = Read-Host "Enter your Hyper-V VM Name"
$vmObject = Get-VM -Name $vm -ErrorAction SilentlyContinue
if (-not $vmObject) {
Write-Host "VM with name '$vm' not found. Please check the name and ensure you're running this script as administrator." -ForegroundColor Red
} else {
Write-Host "VM '$vm' found successfully." -ForegroundColor Green
}
} while (-not $vmObject)
# Ask for user input for number of GPUs
$numGPUs = Read-Host "`nEnter the number of GPUs (1 or 2)"
# Gets info about the GPUs and whether they are partitionable
Write-Host "`nRetrieving information about partitionable GPUs..." -ForegroundColor Yellow
$partitionableGPUs = Get-VMHostPartitionableGpu
# Displaying GPU information
foreach ($gpu in $partitionableGPUs) {
Write-Host "Partitionable GPU found: $($gpu.Name)" -ForegroundColor Yellow
}
# Pausing for user to review GPU information
Write-Host "`nPress Enter to proceed with the configuration..." -ForegroundColor Cyan
$null = Read-Host
# Loop through each GPU based on user input
for ($i=0; $i -lt $numGPUs; $i++) {
$instancePath = $partitionableGPUs[$i].Name
Write-Host "Configuring GPU $i with Instance Path: $instancePath" -ForegroundColor Yellow
# Add GPUs
Write-Host "Adding GPU partition adapter for VM '$vm'..." -ForegroundColor Yellow
Add-VMGpuPartitionAdapter -VMName $vm -InstancePath $instancePath
# GET Adapter IDs for the GPUs
Write-Host "Retrieving GPU adapter IDs..." -ForegroundColor Yellow
$vmobject = Get-VM $vm
$gpus = Get-VMGpuPartitionAdapter -VM $vmobject
$adapterId = $gpus[$i].id
Write-Host "GPU Adapter ID: $adapterId" -ForegroundColor Yellow
# Configure GPU
Write-Host "Setting configurations for GPU partition adapter..." -ForegroundColor Yellow
Set-VMGpuPartitionAdapter -VMName $vm -AdapterId $adapterId -MinPartitionVRAM 80000000 -MaxPartitionVRAM 100000000 -OptimalPartitionVRAM 100000000 -MinPartitionEncode 80000000 -MaxPartitionEncode 100000000 -OptimalPartitionEncode 100000000 -MinPartitionDecode 80000000 -MaxPartitionDecode 100000000 -OptimalPartitionDecode 100000000 -MinPartitionCompute 80000000 -MaxPartitionCompute 100000000 -OptimalPartitionCompute 100000000
Write-Host "GPU configuration completed for adapter ID: $adapterId`n" -ForegroundColor Green
}
# Additional VM settings
Write-Host "Setting additional VM configurations for '$vm'..." -ForegroundColor Yellow
Set-VM -GuestControlledCacheTypes $true -VMName $vm
Set-VM -LowMemoryMappedIoSpace 1GB -VMName $vm
Set-VM -HighMemoryMappedIoSpace 32GB -VMName $vm
Write-Host "Additional VM configurations set." -ForegroundColor Green
Write-Host "`n--------------------------------------------------------------------------"
Write-Host "Script execution complete. If there were no errors, your VM '$vm' is now configured with GPU passthrough.`n" -ForegroundColor Green
# SIG # Begin signature block
# MIIplgYJKoZIhvcNAQcCoIIphzCCKYMCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgE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DHgoMA0GCSqGSIb3
# DQEBAQUABIICAH/9NkI3E0yg61T0Dehdukk1D64lgp+DYwhLGtRG5Ffb6JyH0j06
# iWaEAia780DhkV3eEhilBBw//LGaSu7pUgOT0sStBQMcJ/N4HgS+CzMhwfbwH1XP
# dJvF9Z9XfJDpITZ1cPiVlZEIeroO/KerIx2CEZiP+Z8iLNjygKGYTHfB4VT8CVpB
# 0wIaL3PpVWJq0reRJKmveX56/xgrbgdO8Fmvjpo+5StZ0yUAf5eKfpAw3mhb9CKf
# YmmmkVs+OBBR/ZvO1nBnpEKiepeYu0EOacGc2Yv6g1cISkE5GLzoB0ebeRrhM0l0
# 8tiGDEVMgyRqHLePJw1PT66SV78CRFemKmc8Uo4dBv7eYlwlmPSqgxOdI19rRQya
# 3+gkF3iBxzONepxEnv++7BLu0VmHXXuhfgLnbhBn6dp/5h3wEUpRmiTLOnaFsmXZ
# uGbUqbYTp8GSKH0j5a5HRhlVGmkeNznzuRL3KhpVLLr4spAvQ9fvaaH5bgKZkNeP
# F2kVuMSxIiOpJyJRptXBUCJrReCwEylF4vZ62uhf2xqs82mUOO16oUeuGRUxQe6K
# aYRYeWhOu0U2DEICKx32quJpZTeVw8d/y2XS5wqKGGJQHi+hnhZMa6d8Weu7NTXp
# kr/BGlJxozTnGtVBsw5Ml+I+dzf8aU3Rxai3KmlMErMfwaq7XhdN93Gk
# SIG # End signature block
@tomikcz987
Copy link

Hello, the script is incompatible with windows 10
the Get-VMHostPartitionableGpu command doesn't exist but when removing the "Host" part it looks like this "Get-VMPartitionableGpu" and that works and the last thing when adding graphics to vm "Add-VMGpuPartitionAdapter -VMName $vm -InstancePath $instancePath" doesn't work because it doesn't know -InstancePath $instancePath

@lozhn
Copy link

lozhn commented Jun 8, 2024

Nice gist!

Did you manage to find out what exactly those values mean?

    Set-VMGpuPartitionAdapter -VMName $vm -AdapterId $adapterId -MinPartitionVRAM 80000000 -MaxPartitionVRAM 100000000 -OptimalPartitionVRAM 100000000 -MinPartitionEncode 80000000 -MaxPartitionEncode 100000000 -OptimalPartitionEncode 100000000 -MinPartitionDecode 80000000 -MaxPartitionDecode 100000000 -OptimalPartitionDecode 100000000 -MinPartitionCompute 80000000 -MaxPartitionCompute 100000000 -OptimalPartitionCompute 100000000

Because I read the docs and couldn't move past the

This is defined by the manufacturer's driver

May be you have experimentaly found what those values mean?

@ThioJoe
Copy link
Author

ThioJoe commented Jun 9, 2024

Nice gist!

Did you manage to find out what exactly those values mean?

    Set-VMGpuPartitionAdapter -VMName $vm -AdapterId $adapterId -MinPartitionVRAM 80000000 -MaxPartitionVRAM 100000000 -OptimalPartitionVRAM 100000000 -MinPartitionEncode 80000000 -MaxPartitionEncode 100000000 -OptimalPartitionEncode 100000000 -MinPartitionDecode 80000000 -MaxPartitionDecode 100000000 -OptimalPartitionDecode 100000000 -MinPartitionCompute 80000000 -MaxPartitionCompute 100000000 -OptimalPartitionCompute 100000000

Because I read the docs and couldn't move past the

This is defined by the manufacturer's driver

May be you have experimentaly found what those values mean?

Yea unfortunately I'm not sure myself about the technicality of all those parameters, I mostly just copied values I saw other people using

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment