{"id":13640850,"url":"https://github.com/amd/xdna-driver","last_synced_at":"2025-04-20T07:31:14.730Z","repository":{"id":219030216,"uuid":"747944367","full_name":"amd/xdna-driver","owner":"amd","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-29T18:17:45.000Z","size":1234,"stargazers_count":309,"open_issues_count":6,"forks_count":40,"subscribers_count":26,"default_branch":"main","last_synced_at":"2024-10-29T20:24:56.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.amdnpu","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-25T00:14:59.000Z","updated_at":"2024-10-29T18:17:49.000Z","dependencies_parsed_at":"2024-02-05T06:25:16.449Z","dependency_job_id":"8e7604f1-a818-459a-9ea4-c5ab86ed4e18","html_url":"https://github.com/amd/xdna-driver","commit_stats":null,"previous_names":["amd/xdna-driver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Fxdna-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Fxdna-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Fxdna-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amd%2Fxdna-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amd","download_url":"https://codeload.github.com/amd/xdna-driver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223821936,"owners_count":17208765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:01:15.037Z","updated_at":"2025-04-20T07:31:14.724Z","avatar_url":"https://github.com/amd.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# AMD XDNA™️ Driver for Linux®️\nThis repository is for the AMD XDNA™️ Driver (amdxdna.ko) for Linux®️ and XRT SHIM library development.\n\n## Table of Contents\n- [Introduction](#introduction)\n- [System Requirements](#system-requirements)\n- [Linux compilation and installation](#linux-compilation-and-installation)\n- [Clone](#clone)\n- [Build](#build)\n- [Test](#test)\n- [Q\u0026A](#qa)\n- [Contributor Guidelines](#contributor-guidelines)\n\n## Introduction\nThis repository is for supporting XRT on AMD XDNA devices. From this repository, you can build a XRT plugin DEB package.\nOn a machine with XDNA device, with both XRT and XRT plugin packages installed, user can start using XDNA device on Linux.\n\n## System Requirements\nTo run AI applications, your system needs\n* Processor:\n  - To run AI applications (test machine): RyzenAI processor\n  - To build this repository (build machine): Any x86 processors, but recommend AMD processor :wink:\n* Operating System:\n  - Ubuntu \u003e= 22.04\n  - Arch Linux\n* Linux Kernel: v6.10 or above. (See [Linux compilation and installation](#linux-compilation-and-installation))\n  - Due to Linux API change, XDNA driver doesn't always keep supporting old version.\n* Installed XRT base package (or you can install it along the\n  following recipe)\n  - To make sure the XRT base package works with the plug-in package, better build it from `xrt` submodule in this repo (`\u003croot-of-source-tree\u003e/xrt`)\n  - Refer to https://github.com/Xilinx/XRT for more detailed information.\n\n## Linux compilation and installation\n\n### Ubuntu 24.10\n\nUbuntu 24.10 already includes Linux kernel 6.11 that meets the requirements for the xdna-driver. \n\n### Ubuntu 24.04\n\nIf 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:\n\n  ```bash\n  sudo apt update \n  sudo apt install --install-recommends linux-generic-hwe-24.04\n  sudo reboot\n  ```\n\n### Ubuntu 22.04\n\nSince Linux v6.10 offically supports AMD IOMMU SVA, we can work with upstream Linux kernel source.\nIf 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.\n\nIf you want to manually build Linux kernel, follow below steps.\n```  bash\n# Assuming you have knowledge of kernel compilation,\n# this is just refreshing up a few key points.\n\n# Clone Linux source code from your favorite repository, for example\ngit clone --depth=1 --branch v6.10 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git\n\n# Usually, when people compile kernel from source code, they use current config\ncp /boot/config-`uname -r` \u003cyour_build_dir\u003e/.config   # (Option step, if you know how to do it better)\n# Open \u003cyour_build_dir\u003e/.config and add \"CONFIG_DRM_ACCEL=y\" #Required by XDNA Driver\n# Or run instead\nscripts/config --file .config --enable DRM_ACCEL\nscripts/config --file .config --enable AMD_IOMMU # Option step, if you know this is not set\n\n# Use below command to build kernel packages. Once build is done, DEB packages are at the parent directory of \u003cyour_build_dir\u003e\nmake -j `nproc` bindeb-pkg\n# The exact names will depend on your configuration\nsudo apt reinstall ../linux-headers-6.10.0_6.10.0-1_amd64.deb ../linux-image-6.10.0_6.10.0-1_amd64.deb ../linux-libc-dev_6.10.0-1_amd64.deb\n```\n\n## Clone\n\n```\ngit clone git@github.com:amd/xdna-driver.git\ncd \u003croot-of-source-tree\u003e\n# get code for submodules\ngit submodule update --init --recursive\n```\n\n## Build\n\n### Prerequisite\n\n* If this is your first time building this module,\n  follow below steps to resolve the dependencies (or at least look at\n  the file content if you're not on a distro with apt-get)\n``` bash\n#requires root permissions to run the script\nsudo su\ncd \u003croot-of-source-tree\u003e\n./tools/amdxdna_deps.sh\n# exit from root\nexit\n```\n\n### Steps to create release build DEB package:\n\n``` bash\ncd \u003croot-of-source-tree\u003e/build\n\n# If you do not have XRT installed yet:\ncd xrt/build\n./build.sh -npu -opt\n# To adapt according to your OS \u0026 version\nsudo apt reinstall ./Release/xrt_202510.2.19.0_22.04-amd64-base.deb\ncd ../../build\n\n# Start XDNA driver release build\n./build.sh -release\n\n# Create DEB package for existed release or debug build.\n./build.sh -package\n# To adapt according to your OS \u0026 version\nsudo apt reinstall ./Release/xrt_plugin.2.19.0_ubuntu22.04-x86_64-amdxdna.deb\n```\nYou will find `xrt_plugin\\*-amdxdna.deb` in Release/ folder. This package includes:\n* The `.so` library files, which will be installed into `/opt/xilinx/xrt/lib` folder\n* The XDNA driver and DKMS script, which build, install and load\n  `amdxdna.ko` driver when installing the .DEB package on target machine\n* The firmware binary files, which will be installed to `/usr/lib/firmware/amdnpu` folder\n\n## Test\n\nIf you haven't read [System Requirements](#system-requirements), double check it.\n\n``` bash\nsource /opt/xilinx/xrt/setup.sh\ncd \u003croot-of-source-tree\u003e/build\n\n# Build the test program\n./build.sh -example\n\n# Run the test\n./example_build/example_noop_test ../tools/bins/1502_00/validate.xclbin\n```\n\n## Q\u0026A\n\n### Q: I want to debug my application, how to build library with `-g`?\n\nA: We have debug version of library, which is compiled with `-g` option. You can run `./build.sh -debug` or `./build.sh`.\nTo create a debug DEB package, run `./build.sh -package` afterward.\n\n### Q: I'm developing amdxdna.ko driver module. How to enable XDNA_DBG() print?\n\nA: XDNA_DBG() relies on Linux's CONFIG_DYNAMIC_DEBUG framework, see Linux's [dynamic debug howto page](https://www.kernel.org/doc/html/v6.8/admin-guide/dynamic-debug-howto.html) for details.\nTL;DR, run `sudo insmod amdxdna.ko dyndbg=+pf` to enable XDNA_DBG() globally, where +pf means enable debug printing and print the function name.\n\n### Q: When install XRT plugin DEB package, apt-get/dpkg tool failed. What to do next?\n\nA: Create a debug DEB package, see above question. Then install debug DEB package in your environment. This time, you will have more verbose log. Share this log with us.\n\n### Q: Can I use NPU for accelerate ML training?\n\nA: You can use NPU to accelerate ML inference. But NPU is not designed for ML training.\n\n### Q: How to allocate huge size BO?\n\nA: There is no limit for BO size from the XRT and NPU device.\nAn application can fail to allocate a huge BO, once it hits the Linux resource limit.\nIn our test, the \"max locked memory\" is the key. You can follow below steps to check and change configure.\n``` bash\nulimit -l # The result is in kbytes\n\n# Open /etc/security/limits.conf, add below two lines.\n# * soft  memlock \u003cmax-size-in-kbytes\u003e\n# * hard  memlock \u003cmax-size-in-kbytes\u003e\n#\n# See comments of the file for the meaning of each column.\n\n# Reboot the machine, then check if the limite is changed\nulimit -l\n```\n\n## Contributor Guidelines\n1. Read [Getting Started](#getting-started)\n2. Read [System Requirements](#system-requirements)\n3. Run Linux checkpatch.pl before commit and create pull request, see [Checkpatch](#checkpatch)\n\n### Checkpatch\n* There is a pre-commit script to run checkpatch.pl automatically.\n``` bash\n# How to setup the auto pre-commit check\ncd \u003cworkspace of this repo\u003e/\ncp tools/pre-commit .git/hooks/\n```\n`git commit` will reject the commit if error/warning is found, until you make `checkpatch.pl` happy.\n\n* There is shell script that scan all the source code in a folder\n``` bash\ncd \u003cworkspace of this repo\u003e/\n./tools/codingsty_check.sh \u003cDIR\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famd%2Fxdna-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famd%2Fxdna-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famd%2Fxdna-driver/lists"}