Skip to content

Commit 2de0c82

Browse files
committed
Change way of finding path to GPU device to support both Jetson Nano and Orin
1 parent 565e791 commit 2de0c82

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

kernel_tuner/observers/tegra.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ def __init__(self):
2323
@staticmethod
2424
def get_dev_path():
2525
"""Get the path to device core clock control in /sys"""
26-
root_path = Path("/sys/devices/gpu.0")
27-
gpu_id = root_path.readlink()
28-
return root_path / Path("devfreq") / gpu_id
26+
# loop to find GPU device name based on jetson_clocks
27+
for dev in Path("/sys/class/devfreq").iterdir():
28+
with open(dev / Path("device/of_node/name")) as fp:
29+
name = fp.read().strip().rstrip("\x00")
30+
if name in ("gv11b", "gp10b", "ga10b", "gpu"):
31+
root_path = dev
32+
break
33+
else:
34+
raise FileNotFoundError("No internal tegra GPU found")
35+
return root_path
2936

3037
def _read_railgate_file(self):
3138
"""Read railgate status"""

0 commit comments

Comments
 (0)