MCPcopy Create free account
hub / github.com/mlco2/codecarbon / print_gpu_usage

Function print_gpu_usage

examples/transformers_smollm2.py:31–37  ·  view source on GitHub ↗
(gpu_id)

Source from the content-addressed store, hash-verified

29
30
31def print_gpu_usage(gpu_id):
32 print(
33 f">>>> GPU memoy: {pynvml.nvmlDeviceGetMemoryInfo(gpu_device).used / 1024**3:.2f} GB on {gpu_mem} GB"
34 )
35 print(
36 f">>>> GPU usage: Load {pynvml.nvmlDeviceGetUtilizationRates(gpu_device).gpu} %, memory {pynvml.nvmlDeviceGetUtilizationRates(gpu_device).memory} %"
37 )
38
39
40if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…