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

Method get_gpu_details

codecarbon/core/gpu.py:108–138  ·  view source on GitHub ↗

Get all GPUs instantaneous metrics >>> get_gpu_details() [ { "name": "Tesla V100-SXM2-16GB", "uuid": "GPU-4e817856-1fb8-192a-7ab7-0e0e4476c184", "free_memory": 16945381376, "total_memory": 16945512448,

(self)

Source from the content-addressed store, hash-verified

106 return []
107
108 def get_gpu_details(self) -> List:
109 """Get all GPUs instantaneous metrics
110 >>> get_gpu_details()
111 [
112 {
113 "name": "Tesla V100-SXM2-16GB",
114 "uuid": "GPU-4e817856-1fb8-192a-7ab7-0e0e4476c184",
115 "free_memory": 16945381376,
116 "total_memory": 16945512448,
117 "used_memory": 131072,
118 "temperature": 28,
119 "total_energy_consumption":2000,
120 "power_usage": 42159,
121 "power_limit": 300000,
122 "gpu_utilization": 0,
123 "compute_mode": 0,
124 "compute_processes": [],
125 "graphics_processes": [],
126 }
127 ]
128 """
129 try:
130 devices_info = []
131 for i in range(self.device_count):
132 gpu_device = self.devices[i]
133 devices_info.append(gpu_device.get_gpu_details())
134 return devices_info
135
136 except Exception:
137 logger.warning("Failed to retrieve gpu information", exc_info=True)
138 return []
139
140 def get_delta(self, last_duration: Time) -> List:
141 """Get difference since last time this function was called

Callers 6

test_gpu_detailsMethod · 0.95
test_gpu_not_readyMethod · 0.95
_monitor_powerMethod · 0.45
__repr__Method · 0.45

Calls

no outgoing calls

Tested by 4

test_gpu_detailsMethod · 0.76
test_gpu_not_readyMethod · 0.76