diff --git a/glances/plugins/gpu/cards/nvidia.py b/glances/plugins/gpu/cards/nvidia.py index dd6216de..c677dd57 100644 --- a/glances/plugins/gpu/cards/nvidia.py +++ b/glances/plugins/gpu/cards/nvidia.py @@ -11,11 +11,20 @@ from glances.globals import nativestr from glances.logger import logger +NVML_LIB = 'libnvidia-ml.so.1' + try: + # Avoid importing pynvml if NVML_LIB is not installed + from ctypes import CDLL + CDLL(NVML_LIB) import pynvml +except OSError as e: + nvidia_gpu_enable = False + # NNVML_LIB lib not found (NVidia driver not installed) + logger.warning(f"NVML Shared Library ({NVML_LIB}) not Found, Nvidia GPU plugin is disabled") except Exception as e: nvidia_gpu_enable = False - # Display debug message if import KeyError + # Display warning message if import KeyError logger.warning(f"Missing Python Lib ({e}), Nvidia GPU plugin is disabled") else: nvidia_gpu_enable = True