Add some handling so that if we do not understand /proc/driver/nvidia/version we just fall back to glxinfo instead.

This commit is contained in:
Daniel Johnson 2024-01-06 07:29:22 -05:00
parent 6e130124ce
commit 8b0819fa41
2 changed files with 11 additions and 2 deletions

View file

@ -18,9 +18,9 @@ MIN_RECOMMENDED_NVIDIA_DRIVER = 515
@cache_single
def get_nvidia_driver_info() -> Dict[str, Dict[str, str]]:
"""Return information about NVidia drivers"""
version_file_path = "/proc/driver/nvidia/version"
def read_from_proc() -> Dict[str, Dict[str, str]]:
version_file_path = "/proc/driver/nvidia/version"
try:
if not os.path.exists(version_file_path):
return {}
@ -76,7 +76,14 @@ def get_nvidia_driver_info() -> Dict[str, Dict[str, str]]:
}
}
return read_from_proc() or invoke_glxinfo()
try:
from_proc = read_from_proc()
if from_proc:
return from_proc
except Exception as ex:
logger.exception("Unable to read from '%s': %s", version_file_path, ex)
return invoke_glxinfo()
def get_nvidia_gpu_ids() -> List[str]:

View file

@ -230,6 +230,8 @@ class LinuxSystem: # pylint: disable=too-many-public-methods
minimum_nvidia_version_supported = 515
driver_info = drivers.get_nvidia_driver_info()
driver_version = driver_info["nvrm"]["version"]
if not driver_version:
return False
major_version = int(driver_version.split(".")[0])
return major_version >= minimum_nvidia_version_supported
except Exception as ex: