diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..b0977df2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Shell scripts must use LF line endings; CRLF breaks the shebang +# (e.g. `/usr/bin/env: 'bash\r'`) when COPYed into and executed in containers. +*.sh text eol=lf diff --git a/packages/npu/iron/Dockerfile b/packages/npu/iron/Dockerfile index 75c7d1b5..2c3ce365 100644 --- a/packages/npu/iron/Dockerfile +++ b/packages/npu/iron/Dockerfile @@ -1,14 +1,12 @@ ARG BASE_IMAGE=xdna FROM ${BASE_IMAGE} -# Where we'll install the build backend WORKDIR /ryzers COPY setup.sh /ryzers/setup.sh COPY entrypoint.sh /ryzers/entrypoint.sh -# Set environment variable to suppress prompts in scripts ENV DEBIAN_FRONTEND=noninteractive -SHELL ["/bin/bash", "-l", "-c"] +SHELL ["/bin/bash", "-c"] # IRON requires python venv RUN apt-get -y install python3.12-venv @@ -33,7 +31,7 @@ RUN cd /ryzers/mlir-aie && \ source /opt/xilinx/xrt/setup.sh && \ source /ryzers/mlir-aie/utils/quick_setup.sh -# Copy the new AIE pragma utils.h to mlir_aie/include/ so it's picked up when doing #include "aie_kernel_utils.h" +# Make AIE kernel utils visible to mlir_aie include path RUN cp /ryzers/mlir-aie/aie_kernels/aie_kernel_utils.h /ryzers/mlir-aie/ironenv/lib/python3.12/site-packages/mlir_aie/include/ # Install jupyter for notebooks @@ -43,8 +41,7 @@ RUN source /ryzers/setup.sh && \ # Cleanup ENV SHELL=/bin/bash -# Make sure to source the setup script on docker start ENTRYPOINT ["/ryzers/entrypoint.sh"] COPY test.sh /ryzers/test.sh -CMD ["/ryzers/test.sh"] \ No newline at end of file +CMD ["/ryzers/test.sh"] diff --git a/packages/npu/iron/setup.sh b/packages/npu/iron/setup.sh index e3aedf58..e62deaa9 100755 --- a/packages/npu/iron/setup.sh +++ b/packages/npu/iron/setup.sh @@ -20,10 +20,12 @@ export PEANOWRAP2_FLAGS="-O2 -std=c++20 --target=aie2-none-unknown-elf ${WARNING export PEANOWRAP2P_FLAGS="-O2 -std=c++20 --target=aie2p-none-unknown-elf ${WARNING_FLAGS} -DNDEBUG -I ${MLIR_AIE_INSTALL_DIR}/include " examine_output=$(xrt-smi examine) -if echo $examine_output | grep -E "Phoenix|Hawk" > /dev/null; then - export NPU=npu1 -elif echo $examine_output | grep -E "Strix|Krackan" > /dev/null; then +# Match on AIE architecture (aie2p=npu2, aie2=npu1); check aie2p first since +# "aie2p" contains the substring "aie2". +if echo "$examine_output" | grep -Eiq "Strix|Krackan|aie2p"; then export NPU=npu2 +elif echo "$examine_output" | grep -Eiq "Phoenix|Hawk|aie2"; then + export NPU=npu1 else echo "No recognized NPU found" fi \ No newline at end of file diff --git a/packages/npu/ryzenai_cvml/config.yaml b/packages/npu/ryzenai_cvml/config.yaml index 57f80f8f..4e226d20 100644 --- a/packages/npu/ryzenai_cvml/config.yaml +++ b/packages/npu/ryzenai_cvml/config.yaml @@ -2,7 +2,8 @@ # SPDX-License-Identifier: MIT environment_variables: -- "HSA_OVERRIDE_GFX_VERSION=11.0.0" # Required for HIP to write kernels +# HSA_OVERRIDE_GFX_VERSION is not set: ROCm 7.2.2 detects the iGPUs natively. +# On older ROCm, set it per silicon (see README "Supported silicon"). - "RYZEN_AI_DIR=/ryzers/RyzenAI-SW/Ryzen-AI-CVML-Library" - "LD_LIBRARY_PATH=/ryzers/RyzenAI-SW/Ryzen-AI-CVML-Library/linux:/opt/xilinx/xrt/lib" diff --git a/packages/npu/xdna/Dockerfile b/packages/npu/xdna/Dockerfile index afbe2b45..aec5388a 100644 --- a/packages/npu/xdna/Dockerfile +++ b/packages/npu/xdna/Dockerfile @@ -15,25 +15,31 @@ RUN apt-get update && apt-get install -y \ git \ curl \ bash \ - wget + wget \ + cmake \ + ninja-build \ + build-essential RUN git clone https://github.com/amd/xdna-driver && \ cd xdna-driver && \ git checkout $DRIVER_VERSION && \ git submodule update --init --recursive -# Install build dependencies -RUN cd /ryzers/xdna-driver/tools && \ +# Install build dependencies (xrtdeps.sh -docker skips host kernel headers; jq +# is the only extra package amdxdna_deps.sh would add) +RUN cd /ryzers/xdna-driver && \ apt-get update && \ - ./amdxdna_deps.sh -docker + apt-get install -y jq && \ + ./xrt/src/runtime_src/tools/scripts/xrtdeps.sh -docker # Build XRT RUN cd /ryzers/xdna-driver/xrt/build/ && \ ./build.sh -npu -opt -noctest -# Build XDNA driver (-release also generates the .deb package) +# Build the XDNA userspace (-release generates the xrt_plugin .deb); -nokmod +# skips the kernel module, which is built and loaded on the host (see README) RUN cd /ryzers/xdna-driver/build && \ - ./build.sh -release + ./build.sh -release -nokmod # Finally, save and install the XRT/XDNA debian packages # these will also need to be installed on the host system diff --git a/packages/npu/xdna/README.md b/packages/npu/xdna/README.md index 40e0b518..3e61cac8 100644 --- a/packages/npu/xdna/README.md +++ b/packages/npu/xdna/README.md @@ -48,4 +48,19 @@ Validation completed --- +## Supported silicon + +What differs per platform is the NPU generation (used by IRON) and the iGPU ISA (relevant only if you must set `HSA_OVERRIDE_GFX_VERSION` on an older ROCm stack). On ROCm 7.2.2 the iGPUs are detected natively, so the override is left unset by default (see [config.yaml](config.yaml)). + +| Silicon | NPU gen | iGPU ISA | `HSA_OVERRIDE_GFX_VERSION` (only if needed) | +| --- | --- | --- | --- | +| Phoenix / Hawk Point | `npu1` | gfx1103 | `11.0.0` | +| Strix Point | `npu2` | gfx1150 | `11.5.0` | +| Strix Halo | `npu2` | gfx1151 | `11.5.1` | +| Krackan Point | `npu2` | gfx1152 | `11.5.2` | + +The NPU generation is auto-detected from `xrt-smi examine` output by AIE architecture (`aie2` -> `npu1`, `aie2p` -> `npu2`; the marketing names `Phoenix`/`Hawk` and `Strix`/`Krackan` are also matched as a fallback), see [../iron/setup.sh](../iron/setup.sh). Newer `xrt-smi` (XRT >= 2.20, shipped with ROCm 7.2.x) reports a generic device name, so the architecture string is the stable signal. To force a GPU override on an older ROCm release, add it back to `config.yaml` (`environment_variables`) or pass it at runtime. + +--- + For further details, refer to the official [xdna-driver](https://github.com/amd/xdna-driver) repository. diff --git a/packages/npu/xdna/config.yaml b/packages/npu/xdna/config.yaml index ac542e6a..74aa0ca7 100644 --- a/packages/npu/xdna/config.yaml +++ b/packages/npu/xdna/config.yaml @@ -1,8 +1,8 @@ # Copyright(C) 2025 Advanced Micro Devices, Inc. All rights reserved. # SPDX-License-Identifier: MIT -environment_variables: -- "HSA_OVERRIDE_GFX_VERSION=11.0.0" # Required for HIP to write kernels +# HSA_OVERRIDE_GFX_VERSION is not set: ROCm 7.2.2 detects the iGPUs natively. +# On older ROCm, set it per silicon (see README "Supported silicon"). docker_extra_run_flags: - "--device=/dev/accel/accel0:/dev/accel/accel0"