Skip to content
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Turn off SecureBoot (Allows for unsigned drivers to be installed):
> [0000:66:00.1] : NPU Strix
> ```

IRON requires that `xrt-smi` be in your path.

### Install IRON and MLIR-AIE Prerequisites

1. Install the following packages needed for MLIR-AIE:
Expand Down
24 changes: 2 additions & 22 deletions python/iron/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,12 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# (c) Copyright 2025 Advanced Micro Devices, Inc.

import shutil
import subprocess

from .device import NPU1, NPU2


# Detect WSL
def is_wsl() -> bool:
try:
with open("/proc/sys/kernel/osrelease", "r", encoding="utf-8") as kernel:
return "microsoft" in kernel.read().lower()
except OSError:
return False


# Prefer Windows xrt-smi when in WSL. Linux native otherwise.
def xrt_smi_path() -> str:
if is_wsl():
return "/mnt/c/Windows/System32/AMD/xrt-smi.exe"
return "/opt/xilinx/xrt/bin/xrt-smi"


def detect_npu_device():
"""Detects the current device in the system.
This assumes XRT and XDNA driver is installed
Expand All @@ -37,7 +21,7 @@ def detect_npu_device():
"""
try:
# Run `xrt-smi examine` and capture output
xrt_smi = xrt_smi_path()
xrt_smi = shutil.which("xrt-smi")
result = subprocess.run(
[xrt_smi, "examine"],
check=True,
Expand Down Expand Up @@ -73,10 +57,6 @@ def detect_npu_device():
raise RuntimeError("No supported NPU device found.")

except FileNotFoundError:
if is_wsl():
raise RuntimeError(
"WSL detected but Windows xrt-smi.exe not found. Install AMD Ryzen AI Software."
)
raise RuntimeError("xrt-smi not found. Make sure XRT is installed.")
except subprocess.CalledProcessError:
raise RuntimeError("Failed to run xrt-smi examine.")
Expand Down
3 changes: 2 additions & 1 deletion utils/env_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ fi

XRTSMI=`which xrt-smi`
if ! test -f "$XRTSMI"; then
source /opt/xilinx/xrt/setup.sh
echo "xrt-smi not found. Is XRT installed?"
return 1
fi
NPU=`xrt-smi examine | grep -E "NPU Phoenix|NPU Strix|NPU Strix Halo|NPU Krackan|RyzenAI-npu[1456]"`
NPU="${NPU:-$(/mnt/c/Windows/System32/AMD/xrt-smi.exe examine 2>/dev/null | tr -d '\r' | grep -E 'NPU Phoenix|NPU Strix|NPU Strix Halo|NPU Krackan|RyzenAI-npu[1456]' || true)}"
Expand Down
4 changes: 2 additions & 2 deletions utils/quick_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ echo "Setting up RyzenAI developement tools..."
if [ -z "${WSL_DISTRO_NAME-}" ]; then
XRTSMI=`which xrt-smi`
if ! test -f "$XRTSMI"; then
echo "XRT is not installed"
echo "xrt-smi not found. Is XRT installed?"
return 1
fi
NPU=`/opt/xilinx/xrt/bin/xrt-smi examine | grep -E "NPU Phoenix|NPU Strix|NPU Strix Halo|NPU Krackan|RyzenAI-npu[1456]"`
NPU=`xrt-smi examine | grep -E "NPU Phoenix|NPU Strix|NPU Strix Halo|NPU Krackan|RyzenAI-npu[1456]"`
if echo "$NPU" | grep -qE "NPU Phoenix|NPU Strix|NPU Strix Halo|NPU Krackan|RyzenAI-npu[1456]"; then
echo "AMD XDNA NPU found: "
echo $NPU
Expand Down
4 changes: 0 additions & 4 deletions utils/reset_npu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ if [ x"$NUMBER" != x"" ]; then
sudo modprobe -r amdxdna
sudo modprobe drm_shmem_helper
sudo modprobe amdxdna

# if [ -f "/opt/xilinx/xrt/test/example_noop_test" ]; then
# /opt/xilinx/xrt/test/example_noop_test /lib/firmware/amdipu/1502/validate.xclbin
# fi
else
echo "couldn't find npu"
fi
Expand Down
Loading