Skip to content

Commit

Permalink
more robust test for idle GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Oct 29, 2024
1 parent 47376ed commit 07ab223
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/idle_gpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@
if (s):
gpu = s.group( 1 )

# If using > half the memory, assume it is not idle.
# If using >= 10 MiB or 5% utilization, assume it is not idle.
# Typically idle is 1 MiB and 0% utilization.
# Docker can't see processes in section 2.
s = re.search( '^\| +N/A +\d+C +\w+ +\d+W +/ +\d+W *\| +(\d+)MiB +/ +(\d+)MiB', line )
s = re.search( '^\| +N/A +\d+C +\w+ +\d+W +/ +\d+W *\| +(\d+)MiB +/ +(\d+)MiB *\| +(\d+)%', line )
if (s):
used_mem = int( s.group( 1 ) )
total_mem = int( s.group( 2 ) )
if (used_mem > 0.5*total_mem):
percent = int( s.group( 3 ) )
if (used_mem >= 10 or percent >= 5):
gpus[ gpu ] = 0
else:
# Match process lines:
Expand Down

0 comments on commit 07ab223

Please sign in to comment.