diff --git a/README.md b/README.md index 2ab113f713..b832f2ea87 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/python/iron/config.py b/python/iron/config.py index 73272c4ae4..3192f2c226 100644 --- a/python/iron/config.py +++ b/python/iron/config.py @@ -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 @@ -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, @@ -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.") diff --git a/utils/env_setup.sh b/utils/env_setup.sh index ad319f8076..87c7413ac2 100644 --- a/utils/env_setup.sh +++ b/utils/env_setup.sh @@ -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)}" diff --git a/utils/quick_setup.sh b/utils/quick_setup.sh index 4268924518..77be570478 100644 --- a/utils/quick_setup.sh +++ b/utils/quick_setup.sh @@ -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 diff --git a/utils/reset_npu.sh b/utils/reset_npu.sh index f1a3eaefd4..2016615744 100755 --- a/utils/reset_npu.sh +++ b/utils/reset_npu.sh @@ -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