These instructions will guide you through everything required for building and executing a program on the Ryzen™ AI NPU on Windows. The instructions were tested on a ASUS Vivobook Pro 15.
You will set up a Windows subsystem for Linux (WSL) Ubuntu install, which will be used for building NPU device code. For building the host (x86) code, you will use MS Visual Code Community.
Be sure you have the latest BIOS for your laptop or mini PC, this will ensure the NPU (sometimes referred to as IPU) is enabled in the system. You may need to manually enable the NPU:
Advanced → CPU Configuration → IPU
NOTE: Some manufacturers only provide Windows executables to update the BIOS.
Turn off SecureBoot (Allows for unsigned drivers to be installed)
BIOS → Security → Secure boot → Disable
Turn Ac Power Loss to “Always On” (Can be used for PDU reset, turns computer back on after power loss)
BIOS → Advanced → AMD CBS → FCH Common Options → Ac Power Loss Options → Set Ac Power Loss to "Always On"
All steps in WSL Ubuntu terminal.
git clone --recurse-submodules https://github.com/Xilinx/mlir-aie.git
sudo apt install \
build-essential clang clang-14 lld lld-14 cmake \
libboost-all-dev \
python3-venv python3-pip \
libxrender1 libxtst6 libxi6 \
mingw-w64-tools
apt-get install locales
locale-gen en_US.UTF-8
Install AIETools under WSL Ubuntu
This is an early access lounge, you must register and be granted access at this time.
/tools/ryzen_ai-1.3.0/vitis_aie_essentials
.ryzen_ai-1.3.0ea1.tgz
tar -xzvf ryzen_ai-1.3.0ea1.tgz
cd ryzen_ai-1.3.0
mkdir vitis_aie_essentials
mv vitis_aie_essentials*.whl vitis_aie_essentials
cd vitis_aie_essentials
unzip vitis_aie_essentials*.whl
ip -brief link show eth0
)export XILINXD_LICENSE_FILE=<licenseFilePath>/Xilinx.lic
ip link add vmnic0 type dummy
ip link set vmnic0 addr <yourMACaddress>
#!/bin/bash
#################################################################################
# Setup Vitis AIE Essentials
#################################################################################
export AIETOOLS_ROOT=/tools/ryzen_ai-1.3.0/vitis_aie_essentials
export PATH=$PATH:${AIETOOLS_ROOT}/bin
export LM_LICENSE_FILE=<licenseFilePath>/Xilinx.lic
/tools/Xilinx
.ip -brief link show eth0
)export XILINXD_LICENSE_FILE=<licenseFilePath>/Xilinx.lic
ip link add vmnic0 type dummy
ip link set vmnic0 addr <yourMACaddress>
#!/bin/bash
#################################################################################
# Setup Vitis (which is just for aietools)
#################################################################################
export MYXILINX_VER=2023.2
export MYXILINX_BASE=/tools/Xilinx
export XILINX_LOC=$MYXILINX_BASE/Vitis/$MYXILINX_VER
export AIETOOLS_ROOT=$XILINX_LOC/aietools
export PATH=$PATH:${AIETOOLS_ROOT}/bin
export LM_LICENSE_FILE=<licenseFilePath>/Xilinx.lic
Install or Build mlir-aie tools under WSL2:
Use quick setup script to install from whls:
NOTE: Installing the mlir-aie tools from wheels via the quick setup path supports AMD XDNA™/AIE-ML (AIE2) and AMD XDNA™ 2 (AIE2P), it does NOT support Versal™ devices with AIE.
source utils/quick_setup.sh
# NOTE: this will install mlir-aie in my_install/mlir_aie
# and llvm in my_install/mlir. Be sure to account for this
# using utils/env_setup.sh later on.
[Optional] Build from source following regular get started instructions https://xilinx.github.io/mlir-aie/Building.html
mkdir /mnt/c/Technical/xrtNPUfromDLL; cd /mnt/c/Technical/xrtNPUfromDLL
cp /mnt/c/Windows/System32/AMD/xrt_coreutil.dll .
gendef xrt_coreutil.dll
All steps in Win11 (powershell where needed).
Install Microsoft Visual Studio 17 2022 Community Edition with package for C++ development.
Optional (only needed for vision examples): install opencv and add this install to your PATH environmental variable, for instance C:\Technical\thirdParty\opencv\build\x64\vc16\bin
C:\Technical
and git checkout 2023.2
C:\Technical\xrtNPUfromDLL
and run command:
lib /def:xrt_coreutil.def /machine:x64 /out:xrt_coreutil.lib
To make the compilation toolchain available for use in your WSL terminal, you will need to set some environment variables. We suggest you add the following to a file named setup.sh
, so you can set up your environment easily by running source setup.sh
.
setup.sh
- Option A - Using Quick SetupIf you used the quick setup script (precompiled mlir-aie binaries), use this setup script.
# NOTE: if you did NOT exit the terminal you can skip this step.
cd <yourPathToDesignsWithMLIR-AIE>
source <yourPathToBuildMLIR-AIE>/ironenv/bin/activate
source yourVitisSetupScript (example shown above)
source <yourPathToBuildMLIR-AIE>/utils/env_setup.sh <yourPathToBuildMLIR-AIE>/my_install/mlir_aie <yourPathToBuildMLIR-AIE>/my_install/mlir
setup.sh
- Option B - Built from Sourcecd <yourPathToDesignsWithMLIR-AIE>
source <yourPathToBuildMLIR-AIE>/sandbox/bin/activate
source yourVitisSetupScript (example shown above)
source <yourPathToBuildMLIR-AIE>/utils/env_setup.sh <yourPathToBuildMLIR-AIE>/install <yourPathToBuildMLIR-AIE>/llvm/install
For your design of interest, for instance from programming_examples, 2 steps are needed: (i) build the AIE desgin in WSL and then (ii) build the host code in powershell.
Prepare your enviroment with the mlir-aie tools (built during Prerequisites part of this guide). See Set up your environment above.
Goto the design of interest and run make
.
Note that your design of interest might need an adapted CMakelists.txt file. Also pay attention to accurately set the paths CMake parameters BOOST_ROOT, XRT_INC_DIR and XRT_LIB_DIR used in the CMakelists.txt, either in the file or as CMake command line parameters.
mkdir buildMSVS
cd buildMSVS
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release
cd Release
.\<testName>.exe -x ..\..\build\final.xclbin -k MLIR_AIE -i ..\..\build\insts.txt -v 1