nvml warn once

Signed-off-by: vladmandic <mandic00@live.com>
pull/4493/head
vladmandic 2025-12-22 09:17:15 +01:00
parent 6e86e060ff
commit 4c35d3887e
1 changed files with 10 additions and 1 deletions

View File

@ -8,8 +8,15 @@ except Exception:
nvml_initialized = False
warned = False
def warn_once(msg):
global warned # pylint: disable=global-statement
if not warned:
log.error(msg)
warned = True
def get_reason(val):
throttle = {
1: 'gpu idle',
@ -28,6 +35,8 @@ def get_reason(val):
def get_nvml():
global nvml_initialized # pylint: disable=global-statement
if warned:
return []
try:
from modules.memstats import ram_stats
if not nvml_initialized:
@ -71,7 +80,7 @@ def get_nvml():
# log.debug(f'nmvl: {devices}')
return devices
except Exception as e:
log.error(f'NVML: {e}')
warn_once(f'NVML: {e}')
return []