Skip to content

Instantly share code, notes, and snippets.

@RobertoMaurizzi
Created July 17, 2025 14:33
Show Gist options
  • Save RobertoMaurizzi/8613dd0aae85877ab4f1ba391ca7c26a to your computer and use it in GitHub Desktop.
Save RobertoMaurizzi/8613dd0aae85877ab4f1ba391ca7c26a to your computer and use it in GitHub Desktop.
Steps to compile AMD's XDNA driver on Debian 13

Installing xdna drivers for Ryzen AI HX 370 NPU

Make sure kernel sources and headers are installed

apt install linux-headers-amd64

also make sure the build directory of the kernel headers is a link to the kernel sources, like:

$ l /usr/lib/modules/6.12.25-amd64/build
lrwxrwxrwx 1 root root 40 May 10 19:19 /usr/lib/modules/6.12.25-amd64/build -> ../../../src/linux-headers-6.12.25-amd64

At my second compilation it wasn't and I became stoopid for an hour...

Very important: if you have Secure Boot enabled, you need to properly set up DKMS with a registered MOK (Machine Owner Key) and import it in the BIOS so the boot process will allow your new driver to be loaded. How to do this depends a lot on your computer's BIOS and (partially) on the distro you're using (the process is similar but some paths or details mught be different).

Steps to Build AMD XDNA Driver & XRT on Debian

These steps are derived from the official readme but some steps are executed manually to work around platform-specific problems with the original scripts/instructions.

  1. Clone the repository at https://github.com/amd/xdna-driver then:

  2. cd xdna-driver

  3. git submodule update --init --recursive

  4. become root with sudo su

  5. Install Dependencies

    • Navigated to xdna-driver/ and ran the dependency script:
      ./tools/amdxdna_deps.sh
    • Installed pybind11-dev manually when needed (the above script doesn't manage to install it for Debian):
      apt-get install -y pybind11-dev
  6. Build XRT with NPU Support

    • Edit xdna-driver/xrt/src/CMake/cpackLin.cmake:139 and remove the ubuntu-related IF that was checking if I had Ubuntu 23.10 (you should see the lines in the error messages if it happens like on my system)
    • Navigate to xrt/build/ and run the build script:
      ./build.sh -npu -opt
  7. Install XRT Packages

    • Reinstalled XRT Debian packages after build:
      apt reinstall ./Release/xrt_202510.2.19.0_-amd64-*.deb
    • Source XRT environment:
      source /opt/xilinx/xrt/setup.sh
  8. Built XDNA Driver

    • Returned to xdna-driver/build/, (make sure there's a build directory in the kernel source files directory) and ran:
    • mkdir /lib/modules/6.12.25-amd64/build # create if build is missing

      ./build.sh -release ./build.sh -package
    • Installed the XDNA plugin package:
      apt reinstall ./Release/xrt_plugin.2.19.0_debian-x86_64-amdxdna.deb
  9. Tested the Installation

    • Built and ran the example test:
      ./build.sh -example
      ./example_build/example_noop_test ../tools/bins/1502_00/validate.xclbin

Test passed, printing:

Host test code start...  
Host test code is creating device object...  
Host test code is loading xclbin object...  
Host test code is creating kernel object...  
Host test code kernel name: DPU_PDI_0  
Host code is registering xclbin to the device...  
Host code is creating hw_context...  
Host test code is creating kernel object...  
Host test code allocate buffer objects...  
Host test code sync buffer objects to device...  
Host test code iterations (~10 seconds): 70000  
Host test microseconds: 4522178  
Host test average latency: 64 us/iter  
TEST PASSED!

Key Notes

  • Debugging: Checked xrtdeps.sh and xdna-driver/xrt/src/CMake/cpackLin.cmake for adjustments to Debian (remove the IF starting at line 139 about Ubuntu versions)
  • Dependencies: Installed pybind11-dev manually.
  • Reinstallation: Manually reinstalled XRT and XDNA .deb packages after builds from the newly built .deb files inside ./build/Release/ directories

Debug

root@nadesico:~# xrt-smi examine    
System Configuration  
 OS Name              : Linux  
 Release              : 6.12.25-amd64  
 Machine              : x86_64  
 CPU Cores            : 24  
 Memory               : 47789 MB  
 Distribution         : Debian GNU/Linux trixie/sid  
 GLIBC                : 2.41  
 Model                : AI Series  
 BIOS Vendor          : American Megatrends International, LLC.  
 BIOS Version         : 1.02  
  
XRT  
 Version              : 2.19.0  
 Branch               : HEAD  
 Hash                 : d5835aaa7fcdbcb749f4d837d9a0a605c1a4d312  
 Hash Date            : 2025-05-10 19:05:33  
 amdxdna              : 2.19.0_20250510, b5c9598559bc840efa42ab71a37b988689401ed3  
 virtio-pci           : unknown, unknown  
 NPU Firmware Version : 1.0.9.117  
  
Device(s) Present  
|BDF             |Name       |  
|----------------|-----------|  
|[0000:c6:00.1]  |NPU Strix  |  
  
  
root@nadesico:~# xrt-smi validate  
Validate Device           : [0000:c6:00.1]  
   Platform              : NPU Strix  
   Power Mode            : Performance  
-------------------------------------------------------------------------------  
Test 1 [0000:c6:00.1]     : gemm                                                   
   Details               : TOPS: 51.0  
   Test Status           : [PASSED]  
-------------------------------------------------------------------------------  
Test 2 [0000:c6:00.1]     : latency                                                
   Details               : Average latency: 66.6 us  
   Test Status           : [PASSED]  
-------------------------------------------------------------------------------  
Test 3 [0000:c6:00.1]     : throughput                                             
   Details               : Average throughput: 57201.5 ops  
   Test Status           : [PASSED]  
-------------------------------------------------------------------------------  
Validation completed. Please run the command '--verbose' option for more details

This process gives you a working XDNA driver... but there's currently little to no software for Linux that uses it :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment