Skip to content

Commit c0b6e85

Browse files
committed
Hotfix: if GPU data not available, do not throw exception or repeat warning message in loop
1 parent b7e8839 commit c0b6e85

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

library/stats.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,35 @@ def display_gpu_stats(load, memory_percentage, memory_used_mb, temperature):
229229
gpu_percent_text_data = theme_gpu_data['PERCENTAGE']['TEXT']
230230

231231
if math.isnan(load):
232-
logger.warning("Your GPU load is not supported yet")
233-
gpu_percent_graph_data['SHOW'] = False
234-
gpu_percent_text_data['SHOW'] = False
235-
gpu_percent_radial_data['SHOW'] = False
232+
load = 0
233+
if gpu_percent_graph_data['SHOW'] or gpu_percent_text_data['SHOW'] or gpu_percent_radial_data['SHOW']:
234+
logger.warning("Your GPU load is not supported yet")
235+
gpu_percent_graph_data['SHOW'] = False
236+
gpu_percent_text_data['SHOW'] = False
237+
gpu_percent_radial_data['SHOW'] = False
236238

237239
gpu_mem_graph_data = theme_gpu_data['MEMORY']['GRAPH']
240+
gpu_mem_radial_data = theme_gpu_data['MEMORY']['RADIAL']
238241
if math.isnan(memory_percentage):
239-
logger.warning("Your GPU memory relative usage (%) is not supported yet")
240-
gpu_mem_graph_data['SHOW'] = False
242+
memory_percentage = 0
243+
if gpu_mem_graph_data['SHOW'] or gpu_mem_radial_data['SHOW']:
244+
logger.warning("Your GPU memory relative usage (%) is not supported yet")
245+
gpu_mem_graph_data['SHOW'] = False
246+
gpu_mem_radial_data['SHOW'] = False
241247

242248
gpu_mem_text_data = theme_gpu_data['MEMORY']['TEXT']
243249
if math.isnan(memory_used_mb):
244-
logger.warning("Your GPU memory absolute usage (M) is not supported yet")
245-
gpu_mem_text_data['SHOW'] = False
250+
memory_used_mb = 0
251+
if gpu_mem_text_data['SHOW']:
252+
logger.warning("Your GPU memory absolute usage (M) is not supported yet")
253+
gpu_mem_text_data['SHOW'] = False
246254

247255
gpu_temp_text_data = theme_gpu_data['TEMPERATURE']['TEXT']
248256
if math.isnan(temperature):
249-
logger.warning("Your GPU temperature is not supported yet")
250-
gpu_temp_text_data['SHOW'] = False
257+
temperature = 0
258+
if gpu_temp_text_data['SHOW']:
259+
logger.warning("Your GPU temperature is not supported yet")
260+
gpu_temp_text_data['SHOW'] = False
251261

252262
# logger.debug(f"GPU Load: {load}")
253263
display_themed_progress_bar(gpu_percent_graph_data, load)
@@ -261,7 +271,7 @@ def display_gpu_stats(load, memory_percentage, memory_used_mb, temperature):
261271
display_themed_progress_bar(gpu_mem_graph_data, memory_percentage)
262272

263273
display_themed_radial_bar(
264-
theme_data=theme_gpu_data['MEMORY']['RADIAL'],
274+
theme_data=gpu_mem_radial_data,
265275
value=int(memory_percentage),
266276
min_size=3,
267277
unit="%"

0 commit comments

Comments
 (0)