Skip to content

Instantly share code, notes, and snippets.

@InnovativeInventor
Created June 2, 2022 22:05
Show Gist options
  • Save InnovativeInventor/97f3e31b2ce0cb5248ed0e64799a1ac5 to your computer and use it in GitHub Desktop.
Save InnovativeInventor/97f3e31b2ce0cb5248ed0e64799a1ac5 to your computer and use it in GitHub Desktop.
import sys
"""
Example usage (on slurm cluster):
scontrol show nodes | python cores.py | sort -n
Outputs list of free cores per node, along with the load.
"""
for line in sys.stdin:
if "CPUTot" in line:
parsed = line.split()
try:
load = float(parsed[2].split("=")[1])
if load > 1:
print(int(parsed[1].split("=")[1]) - int(parsed[0].split("=")[1]), "avail with load", load)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment