Skip to content

Commit 172a3e2

Browse files
LtdJorgedmitrii-galantsev
authored andcommitted
Updates driverInitialized() to support amdgpu built as module as well as kernel built-in. Fixes ROCm/rocm_smi_lib#102 and is an updated version of ROCm/rocm_smi_lib#104
Change-Id: Icb3abe820bc67035b822358a1c04bd09a7c22b6b Signed-off-by: Galantsev, Dmitrii <[email protected]> Reviewed-by: Galantsev, Dmitrii <[email protected]>
1 parent 02cbffb commit 172a3e2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

rocm_smi/python_smi_tools/rocm_smi.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@
7171
def driverInitialized():
7272
""" Returns true if amdgpu is found in the list of initialized modules
7373
"""
74-
driverInitialized = ''
75-
try:
76-
driverInitialized = str(subprocess.check_output("cat /sys/module/amdgpu/initstate |grep live", shell=True))
77-
except subprocess.CalledProcessError:
78-
pass
79-
if len(driverInitialized) > 0:
80-
return True
81-
return False
74+
driverInitialized = False
75+
if os.path.exists("/sys/module/amdgpu") :
76+
if os.path.exists("/sys/module/amdgpu/initstate"):
77+
# amdgpu is loadable module
78+
with open("/sys/module/amdgpu/initstate") as initstate:
79+
if 'live' in initstate.read():
80+
driverInitialized = True
81+
else:
82+
# amdgpu is built into the kernel
83+
driverInitialized = True
84+
return driverInitialized
8285

8386

8487
def formatJson(device, log):

0 commit comments

Comments
 (0)