@@ 62-84 (lines=23) @@ | ||
59 | def exit(self): |
|
60 | """Close AMD GPU class.""" |
|
61 | ||
62 | def get_device_stats(self): |
|
63 | """Get AMD GPU stats.""" |
|
64 | stats = [] |
|
65 | ||
66 | for index, device in enumerate(self.device_folders): |
|
67 | device_stats = {} |
|
68 | # Dictionary key is the GPU_ID |
|
69 | device_stats['key'] = 'gpu_id' |
|
70 | # GPU id (for multiple GPU, start at 0) |
|
71 | device_stats['gpu_id'] = f'amd{index}' |
|
72 | # GPU name |
|
73 | device_stats['name'] = get_device_name(device) |
|
74 | # Memory consumption in % (not available on all GPU) |
|
75 | device_stats['mem'] = get_mem(device) |
|
76 | # Processor consumption in % |
|
77 | device_stats['proc'] = get_proc(device) |
|
78 | # Processor temperature in °C |
|
79 | device_stats['temperature'] = get_temperature(device) |
|
80 | # Fan speed in % |
|
81 | device_stats['fan_speed'] = get_fan_speed(device) |
|
82 | stats.append(device_stats) |
|
83 | ||
84 | return stats |
|
85 | ||
86 | ||
87 | def get_device_list(drm_root_folder: str) -> list: |
@@ 66-88 (lines=23) @@ | ||
63 | except Exception as e: |
|
64 | logger.debug(f"pynvml failed to shutdown correctly ({e})") |
|
65 | ||
66 | def get_device_stats(self): |
|
67 | """Get Nvidia GPU stats.""" |
|
68 | stats = [] |
|
69 | ||
70 | for index, device_handle in enumerate(self.device_handles): |
|
71 | device_stats = {} |
|
72 | # Dictionary key is the GPU_ID |
|
73 | device_stats['key'] = 'gpu_id' |
|
74 | # GPU id (for multiple GPU, start at 0) |
|
75 | device_stats['gpu_id'] = f'nvidia{index}' |
|
76 | # GPU name |
|
77 | device_stats['name'] = get_device_name(device_handle) |
|
78 | # Memory consumption in % (not available on all GPU) |
|
79 | device_stats['mem'] = get_mem(device_handle) |
|
80 | # Processor consumption in % |
|
81 | device_stats['proc'] = get_proc(device_handle) |
|
82 | # Processor temperature in °C |
|
83 | device_stats['temperature'] = get_temperature(device_handle) |
|
84 | # Fan speed in % |
|
85 | device_stats['fan_speed'] = get_fan_speed(device_handle) |
|
86 | stats.append(device_stats) |
|
87 | ||
88 | return stats |
|
89 | ||
90 | ||
91 | def get_device_list(): |