MCPcopy Create free account
hub / github.com/AnswerDotAI/ModernBERT / get_gpu_memory_usage

Function get_gpu_memory_usage

run_evals.py:97–110  ·  view source on GitHub ↗

Get memory usage for a specific GPU.

(gpu_id)

Source from the content-addressed store, hash-verified

95
96
97def get_gpu_memory_usage(gpu_id):
98 """Get memory usage for a specific GPU."""
99 try:
100 output = (
101 subprocess.check_output(
102 f"nvidia-smi --query-gpu=memory.used --format=csv,nounits,noheader -i {gpu_id}", shell=True
103 )
104 .decode("utf-8")
105 .strip()
106 )
107 return int(output)
108 except subprocess.CalledProcessError:
109 print(f"Failed to get memory usage for GPU {gpu_id}")
110 return None
111
112
113def get_free_gpu():

Callers 1

get_free_gpuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected