适用于 Linux 和 XRT SHIM 库的 AMD XDNA 驱动程序 (amdxdna.ko)
This repository is for the AMD XDNA™️ Driver (amdxdna.ko) for Linux®️ and XRT SHIM library development.
This repository is for supporting XRT on AMD XDNA devices. From this repository, you can build a XRT plugin DEB package. On a machine with XDNA device, with both XRT and XRT plugin packages installed, user can start using XDNA device on Linux.
To run AI applications, your system needs
xrt submodule in this repo (/xrt)Ubuntu 25.04 includes Linux kernel 6.14 that incorporates the amdxdna driver for AMD NPUs :partying_face:.
The XRT SHIM library is still needed from this repository.
Ubuntu 24.10 includes Linux kernel 6.11 that meets the requirements for the xdna-driver.
If you are using Ubuntu 24.04 you may need to update the Linux kernel. You can update to Linux 6.11 by installing the Hardware Enablement (HWE) stack:
sudo apt update
sudo apt install --install-recommends linux-generic-hwe-24.04
sudo rebootSince Linux v6.10 officially supports AMD IOMMU SVA, we can work with upstream Linux kernel source.
If your system has Linux v6.10 or above installed, check if CONFIG_AMD_IOMMU and CONFIG_DRM_ACCEL are set. If not, the system is not good for XDNA driver.
If you want to manually build Linux kernel, follow below steps.
…The vtd submodule stores binary archives via Git LFS. Install git-lfs
and run git lfs install once before cloning (or before running
git submodule update):
# Ubuntu/Debian
sudo apt-get install git-lfs
# Fedora/RHEL
sudo dnf install git-lfs
# Arch Linux
sudo pacman -S git-lfs
# Register LFS hooks globally (once per machine)
git lfs installgit clone [email protected]:amd/xdna-driver.git
cd
# get code for submodules
git submodule update --init --recursive#requires root permissions to run the script
sudo su
cd
./tools/amdxdna_deps.sh
# exit from root
exitcd /build
# If you do not have XRT installed yet:
cd xrt/build
./build.sh -npu -opt
# Then follow the installation guide in test
# Then build the xdna driver
cd ../../build
# Start XDNA driver release build and create release DEB package
./build.sh -releaseFollow the installation guide in the Test to install and test.
…Follow the installation guide in the Test to install and test. Arch users are also advised to configure memory limits required for NPU access.
Note for Arch Linux users: The build system generates .tar.gz packages which are repackaged into proper Arch packages (.pkg.tar.zst) using the provided PKGBUILDs:
xrt/build/arch/ (PKGBUILD-xrt-base, PKGBUILD-xrt-npu)build/arch/ (PKGBUILD-amdxdna-driver)build/arch/ (PKGBUILD-xrt-plugin-amdxdna)This ensures proper integration with pacman for installation, upgrades, and removal.
The kernel driver lives in drivers/accel/amdxdna/, mirrored from the
Linux kernel staging tree.
./build.sh -release builds the driver and packages it into the plugin DEB:
amdxdna.ko — built from the upstream (staging) tree. DKMS compiles it
on install and modprobe loads it automatically.You will find xrt_plugin._--amdxdna.deb (Ubuntu/Debian) or xrt_plugin._--amdxdna.tar.gz (Arch Linux) in the Release/ folder. This package includes:
.so library files, which will be installed into /opt/xilinx/xrt/lib folderamdxdna.ko on the target machine./usr/lib/firmware/amdnpu foldercd
# Install dependencies (requires sudo)
sudo ./tools/amdxdna_deps.sh
# Get submodules
git submodule update --init --recursive
# Build XRT
cd xrt/build
./build.sh -npu -opt
# Build XDNA driver
cd ../../build
./build.sh -releaseFollow the installation guide in the Test to install and test.
If you haven't read System Requirements, double check it. Install the driver (if not already) and the plugin package generated during Build for your platform, then validate.
Ubuntu/Debian:
sudo apt reinstall ./Release/xrt_plugin.2.19.0_ubuntu22.04-x86_64-amdxdna.debArch Linux:
…Note (Fedora): if ulimit -l still reports a low value (e.g. 8192) after setting the
drop-in file above, Fedora's systemd --user may also need a higher memlock limit:
sudo systemctl edit [email protected]Add:
[Service]
LimitMEMLOCK=infinityLog out and log back in (or reboot), then verify:
ulimit -l
xrt-smi examinexrt-smi enumerates the NPU, but commands abort (ERT_CMD_STATE_ABORT) or the mailbox times out right after load. What's wrong?A: This is almost always a firmware/driver version mismatch — a stale NPU firmware
(npu.sbin) left over from a previous or distro install does not match the loaded amdxdna.ko.
The plugin package ships the matching firmware to /usr/lib/firmware/amdnpu//; make sure
that copy is the one in use (re-install the plugin package, or remove a stale firmware you placed
by hand), then reload the driver. Mixing a firmware version from one source with a driver from
another is the common cause of post-load command aborts.
EINVAL (e.g. GET_ARRAY, QUERY_TELEMETRY). Why?A: Your XRT/plugin is newer than the loaded kernel driver. A distro in-tree amdxdna can
predate ioctls that the current XRT SHIM issues, so those calls return EOPNOTSUPP/EINVAL while
basic BO/exec paths still work. Use the driver built and shipped from this repo (the staging
amdxdna.ko — see Driver in the plugin package,
which implements the matching ioctls, rather than an older in-tree module.
# How to setup the auto pre-commit check
cd /
cp tools/pre-commit .git/hooks/git commit will reject the commit if error/warning is found, until you make checkpatch.pl happy.
cd /
./tools/codingsty_check.sh 暂无开放 Issues,或尚未同步最近议题。