Skip to content

Commit 0ab16c2

Browse files
committed
Updates driverInitialized() to support amdgpu built as module as well as kernel built-in. Fixes ROCm#102 and is an updated version of ROCm#104
1 parent c9201f7 commit 0ab16c2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

python_smi_tools/rocm_smi.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@
8888
def driverInitialized():
8989
""" Returns true if amdgpu is found in the list of initialized modules
9090
"""
91-
driverInitialized = ''
92-
try:
93-
driverInitialized = str(subprocess.check_output("cat /sys/module/amdgpu/initstate |grep live", shell=True))
94-
except subprocess.CalledProcessError:
95-
pass
96-
if len(driverInitialized) > 0:
97-
return True
98-
return False
91+
driverInitialized = False
92+
if os.path.exists("/sys/module/amdgpu") :
93+
if os.path.exists("/sys/module/amdgpu/initstate"):
94+
# amdgpu is loadable module
95+
with open("/sys/module/amdgpu/initstate") as initstate:
96+
if 'live' in initstate.read():
97+
driverInitialized = True
98+
else:
99+
# amdgpu is built into the kernel
100+
driverInitialized = True
101+
return driverInitialized
99102

100103

101104
def formatJson(device, log):

0 commit comments

Comments
 (0)