From 7a3c40362ba6e15f78afc23b839741fbfe33e101 Mon Sep 17 00:00:00 2001 From: Jagadeesh J Date: Tue, 12 Apr 2022 01:13:56 +0530 Subject: [PATCH 1/2] Update dcgm_structs.py --- testing/python/dcgm_structs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/python/dcgm_structs.py b/testing/python/dcgm_structs.py index 20d549ea..56ae187f 100644 --- a/testing/python/dcgm_structs.py +++ b/testing/python/dcgm_structs.py @@ -24,6 +24,7 @@ import json import dcgmvalue import platform +import distro DCGM_MAX_STR_LENGTH = 256 DCGM_MAX_NUM_DEVICES = 32 # DCGM 2.0 and newer = 32. DCGM 1.8 and older = 16 @@ -452,11 +453,11 @@ def _LoadDcgmLibrary(libDcgmPath=None): dcgmLib = CDLL(os.path.join(os.getenv("ProgramFiles", "C:/Program Files"), "NVIDIA Corporation/NVSMI/dcgm.dll")) else: if not libDcgmPath: - dist_name, dist_version, dist_id = platform.linux_distribution(full_distribution_name=0) + dist_name, dist_version, dist_id = distro.linux_distribution(full_distribution_name=0) dist_name = dist_name.lower() if dist_name in {'ubuntu', 'debian'}: libDcgmPath = '/usr/lib/{}-linux-gnu'.format(platform.machine()) - elif dist_name in {'fedora', 'redhat', 'centos', 'suse'}: + elif dist_name in {'fedora', 'redhat', 'centos', 'suse', 'amzn'}: libDcgmPath = '/usr/lib64' dcgmLib = CDLL(os.path.join(libDcgmPath, "libdcgm.so.2")) From e51325831d02713746df9e222c29bdd9668083ea Mon Sep 17 00:00:00 2001 From: Jagadeesh J Date: Mon, 2 May 2022 18:06:29 +0530 Subject: [PATCH 2/2] fix: remove distro package Signed-off-by: Jagadeesh J --- testing/python/dcgm_structs.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/testing/python/dcgm_structs.py b/testing/python/dcgm_structs.py index 56ae187f..3845a57b 100644 --- a/testing/python/dcgm_structs.py +++ b/testing/python/dcgm_structs.py @@ -24,7 +24,7 @@ import json import dcgmvalue import platform -import distro +import csv DCGM_MAX_STR_LENGTH = 256 DCGM_MAX_NUM_DEVICES = 32 # DCGM 2.0 and newer = 32. DCGM 1.8 and older = 16 @@ -453,7 +453,7 @@ def _LoadDcgmLibrary(libDcgmPath=None): dcgmLib = CDLL(os.path.join(os.getenv("ProgramFiles", "C:/Program Files"), "NVIDIA Corporation/NVSMI/dcgm.dll")) else: if not libDcgmPath: - dist_name, dist_version, dist_id = distro.linux_distribution(full_distribution_name=0) + dist_name = get_distro()['ID'] dist_name = dist_name.lower() if dist_name in {'ubuntu', 'debian'}: libDcgmPath = '/usr/lib/{}-linux-gnu'.format(platform.machine()) @@ -461,7 +461,7 @@ def _LoadDcgmLibrary(libDcgmPath=None): libDcgmPath = '/usr/lib64' dcgmLib = CDLL(os.path.join(libDcgmPath, "libdcgm.so.2")) - + except OSError as ose: _dcgmCheckReturn(DCGM_ST_LIBRARY_NOT_FOUND) if dcgmLib is None: @@ -507,6 +507,14 @@ def _dcgmErrorString(result): str = fn(result) return str +def get_distro(): + RELEASE_INFO={} + with open("/etc/os-release") as f: + reader = csv.reader(f, delimiter="=") + for row in reader: + RELEASE_INFO[row[0]] = row[1] + return RELEASE_INFO + class c_dcgmConnectV2Params_v1(_PrintableStructure): _fields_ = [ ('version', c_uint),