mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-24 05:15:47 +03:00
Avoid importing pynvml if NVML_LIB is not installed
This commit is contained in:
parent
a6956bf7ee
commit
49d15b20da
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user