Skip to content

Commit

Permalink
Updates driverInitialized() to support amdgpu built as module as well…
Browse files Browse the repository at this point in the history
… 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 <dmitrii.galantsev@amd.com>
Reviewed-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
  • Loading branch information
LtdJorge authored and dmitrii-galantsev committed Nov 5, 2024
1 parent 02cbffb commit 172a3e2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions rocm_smi/python_smi_tools/rocm_smi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@
def driverInitialized():
""" Returns true if amdgpu is found in the list of initialized modules
"""
driverInitialized = ''
try:
driverInitialized = str(subprocess.check_output("cat /sys/module/amdgpu/initstate |grep live", shell=True))
except subprocess.CalledProcessError:
pass
if len(driverInitialized) > 0:
return True
return False
driverInitialized = False
if os.path.exists("/sys/module/amdgpu") :
if os.path.exists("/sys/module/amdgpu/initstate"):
# amdgpu is loadable module
with open("/sys/module/amdgpu/initstate") as initstate:
if 'live' in initstate.read():
driverInitialized = True
else:
# amdgpu is built into the kernel
driverInitialized = True
return driverInitialized


def formatJson(device, log):
Expand Down

0 comments on commit 172a3e2

Please sign in to comment.