Last active
July 13, 2022 17:33
-
-
Save AzimsTech/6c3edac88495a82ac359db03552cdc98 to your computer and use it in GitHub Desktop.
PowerShell script to create a scheduled task that sets GPU Power Limits at machine startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See if nvidia-smi.exe is available. If not, stop execution | |
$nvCmd = Get-Command -Name 'nvidia-smi' -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select-Object -ExpandProperty Source | |
if ($nvCmd -eq $null) { break } | |
# Settings for the scheduled task | |
$taskAction = New-ScheduledTaskAction -Execute $nvCmd -Argument '-pl 30' | |
$taskTrigger = New-ScheduledTaskTrigger -AtStartup | |
$taskUserPrincipal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' | |
$taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 | |
# Set up the task, and register it | |
$task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Trigger $taskTrigger -Settings $taskSettings | |
Register-ScheduledTask -TaskName 'Set GPU power limit at 30W on Startup' -InputObject $task -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment