/build/static/layout/Breadcrumb_cap_w.png

How to kill a App once GPU Usage is below set Threshold using a given GPU? per nvidia-smi in Windows

Would love to know how to integrate GPU Threshold once reached.


For example below 10% Usage for the Program/App to exit and if possible in a batch file, I've tried with a mix of CPU+memory threshold but that don't always work properly in all Apps, so I thought GPU threshold would solve this since it is pretty definite at times unlike CPU+memory thresholds which can vary greatly sometimes.


Here's a batch example for the threshold that needs a GPU threshold included, btw this does not work in its current state, its supposed to kill folding.exe once it reaches gpu usage below 20%, you can test this with any gpu bound app really  >


@echo OFF

@start "" "folding.exe"

TIMEOUT /t 20

:: set process_name:

 set process_name=folding.exe

 ::=================================================================

cd /D "C:\Program Files\NVIDIA Corporation\NVSMI\"

:GPU

for /f skip^=8^ tokens^=1-3^ delims^=^| %%a in ('"nvidia-smi.exe"') do (

    for /f "tokens=1-6 delims= " %%g in ("%%a") do set u=%%g & set v=%%h) & set w=%%j) & (

    for /f "tokens=1-3 delims= " %%g in ("%%b") do set x=%%g & set y=%%i) & (

    for /f "tokens=1-2 delims= " %%g in ("%%c") do set z=%%g) & goto :breakForLoop

:breakForLoop

set /a u+=0 & set /a v+=0 & set /a w+=0 & set /a x+=0 & set /a z+=0

set /a u=u & set /a v=v & set /a w=w & set /a x=x & set /a z=z

echo %u%, %v%, %w%, %x%, %y%, %z%

pause

timeout /t 5

goto GPU

if %z% Lss 20 TaskKill /F /im %process_name% & goto RUNNING

timeout /t 3

:RUNNING

tasklist|findstr %process_name% > nul &&

    taskkill /F /T /IM "Werfault.exe" & exit /b

timeout /t 1

GOTO RUNNING



2 Comments   [ + ] Show comments
  • I can do this in PowerShell for you as well if you like? - rileyz 3 years ago
  • well ...whatever freakin works my dude ...im at ends wit over here getting this to work - tobsto occupied 3 years ago

Answers (1)

Posted by: tobsto occupied 3 years ago
Senior White Belt
1

well would still love a solution for this issue no doubt since ive been pulling my hair out at this issue

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ