Skip to content

Instantly share code, notes, and snippets.

@AzimsTech
Last active July 13, 2022 17:33
Show Gist options
  • Save AzimsTech/6c3edac88495a82ac359db03552cdc98 to your computer and use it in GitHub Desktop.
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
# 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