• Stars
    star
    274
  • Rank 150,250 (Top 3 %)
  • Language
    C
  • License
    Other
  • Created 9 months ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AMD XDNA™️ Driver for Linux®️

This repository is for the AMD XDNA™️ Driver (amdxdna.ko) for Linux®️ and XRT SHIM library development.

Table of Contents

Introduction

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.

System Requirements

To run AI applications, your system needs

  • Processor:
    • To run AI applications (test machine): RyzenAI processor
    • To build this repository (build machine): Any x86 processors, but recommend AMD processor 😉
  • Operating System: Ubuntu 22.04
  • Linux Kernel: v6.8 with IOMMU SVA support (see below)
  • Installed XRT base package
    • To make sure the XRT base package works with the plug-in package, better build it from xrt submodule in this repo (/xrt)
    • Refer to https://github.com/Xilinx/XRT for more detailed information.

Important: IOMMU SVA in Linux kernel support is required.

You need to manually build 6.8 Linux kernel packages by following below steps.

The 6.8 Linux kernel with SVA source code can be downloaded from iommu_sva_part4_v6_v6.8_rc2 on https://github.com/AMDESE/linux

# Assuming you have knowledge of kernel compile, this just refreshing up a few key points.

git clone --branch iommu_sva_part4_v6_v6.8_rc2 [email protected]:AMDESE/linux.git 
cd linux/

# Usually, when people compile kernel from source code, they use current config.
cp /boot/config-`uname -r` <your_build_dir>/.config   # (Option step, if you know how to do it better)
# Open <your_build_dir>/.config and add "CONFIG_DRM_ACCEL=y" # Required by XDNA Driver

# Use below command to build kernel packages. Once build is done, DEB packages are at the parent directory of <your_build_dir>
make ARCH=x86 O=<your_build_dir> bindeb-pkg -j4

Clone

This repository has src/xrt as a git submodule. The path to XRT is set up to clone as ssh, so you need a public key registered with your GitHub.com account.

% git clone [email protected]:amd/xdna-driver.git
% cd <root-of-source-tree>
# get code for submodules
% git submodule update --init --recursive

Build

Prerequisite

  • If this is your first time building this module, follow below steps to resolve the dependencies.
sudo su 	#requires root permissions to run the script
cd <root-of-source-tree>
./tools/amdxdna_deps.sh
exit  		#exit from root

Steps to create release build DEB package:

cd <root-of-source-tree>/build

# Start release build
./build.sh -release

# Create DEB package for existed release or debug build.
./build.sh -package

You will find "xrt_plugin*-amdxdna.deb" in Release/ folder. This package includes below content:

  • The .so library files, which will be install to /opt/xilinx/xrt/libs folder
  • The XDNA driver and DKMS script, which build, install and load amdxdna.ko driver when install DEB package on target machine
  • The firmware binary files, which will be installed to /lib/firmware/amdnpu folder

Test

If you haven't read System Requirements, double check it.

source /opt/xilinx/xrt/setup.sh
cd <root-of-source-tree>/build

# Build the test program
./build.sh -example

# Run the test (test xclbins can be found under /lib/firwmare/amdnpu/<deviceID>/validate.xclbin
./example_build/example_noop_test <path-to-xclbin>

Q&A

Q: I want to debug my application, how to build library with '-g'?

A: We have debug version of library, which is compiled with '-g' option. You can run ./build.sh -debug or ./build.sh. To create a debug DEB package, run ./build.sh -package afterward.

Q: When build -release or -debug, can I specify linux kernel version different than currently running linux kernel?

A: Yes. For example, if you have 6.6-rc1 linux header install on your build machine. Run ./build.sh [-debug|-release] -kernel_ver 6.6-rc1

Q: I'm developing amdxdna.ko driver module. How to enable XDNA_DBG() print?

A: XDNA_DBG() relies on Linux's CONFIG_DYNAMIC_DEBUG framework, see Linux's dynamic debug howto page for details. TL;DR, run sudo insmod amdxdna.ko dyndbg==p to enable XDNA_DBG() globally.

Q: When install XRT plugin DEB package, apt-get/dpkg tool failed. What to do next?

A: 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.

Q: I see "Failed to load xclbin firmware" error in dmesg. How to fix this?

A: In amdxdna driver, it will not directly use the xclbin passed from application. Instead, it loads verified xclbin from /lib/firmware/amdnpu/ directory. The driver will check if the UUID of the xclbin from application and firmware directory matched. If this match process failed, you will see this error.

Q: I need to test a unverified xclbin . I know what I'm doing. Can I get rid of the "Failed to load xclbin firmware" error?

A: Yes. Make sure you have root privilege of the system. Follow below steps,

# Assume you already have xrt_plugin DEB package installed
# You need root privilege to install firmware
sudo bash

source /opt/xilinx/xrt/setup.sh

# List supported device(s)
/opt/xilinx/xrt/amdxdna/setup_xclbin_firmware.sh -list

# Assume adding an unsigned xclbin on Phoenix, run
/opt/xilinx/xrt/amdxdna/setup_xclbin_firmware.sh -dev Phoenix -xclbin <test>.xclbin

# When xrt_plugin package is removed, it will be automaticlly cleaned up.
# User is able to setup multiple xclbins. But if setup two xclbins with the same file name,
# the previous one will be overwritten.

Contributor Guidelines

  1. Read Getting Started
  2. Read System Requirements
  3. Run Linux checkpatch.pl before commit and create pull request, see Checkpatch

Checkpatch

There is a pre-commit script for this purpose.

cp amd-aie/tools/pre-commit <root-of-source-tree>/.git/hooks/

git commit will reject the commit if error/warning is found, until you make checkpatch.pl happy.

More Repositories

1

OpenCL-caffe

This is a Experimental version of OpenCL by AMD Research, we now recommend you to use The official BVLC Caffe OpenCL branch is over at Caffe branch now at https://github.com/BVLC/caffe/tree/opencl
C++
514
star
2

RyzenAI-SW

C++
368
star
3

aocl-libm-ose

AOCL-LibM
C
99
star
4

Chromium-WebCL

WebCL implementation for Chromium
C
91
star
5

amd-lab-notes

AMD lab notes with code examples to demonstrate use of AMD GPUs
C++
88
star
6

ZenDNN

C++
80
star
7

furious.js

scientific computing package for JavaScript - inspired by NumPy
JavaScript
79
star
8

AMD-ASPFW

C
79
star
9

UIF

57
star
10

fuzzyHSA

Python
50
star
11

amd-fftw

FFTW code optimized for AMD based processors
C
47
star
12

firmware_binaries

Administrator : [email protected]
C
45
star
13

ryzen-ai-documentation

Onboarding documentation source for the AMD Ryzen™ AI Software Platform. The AMD Ryzen™ AI Software Platform enables developers to take pretrained machine learning models in popular frameworks and run them on laptops powered by AMD Ryzen™ AI technology.
44
star
14

HPCTrainingExamples

C++
37
star
15

amd_smi_exporter

The AMD SMI Exporter exports AMD EPYC CPU & Datacenter GPU metrics to the Prometheus server.
Go
29
star
16

amd_energy

C
28
star
17

apml_modules

AMD APML modules, apml_sbtsi and apml_sbrmi registers to hwmon framework provding temperature and power metrics of the socket. They are extended by registering a misc_device, which provides ioctl interface to BMC admins.
C
26
star
18

amd_hsmp

AMD HSMP module to provide user interface to system management features.
C
26
star
19

aocl-sparse

AMD optimized Sparse Linear Algebra library
C++
23
star
20

esmi_ib_library

E-SMI: EPYC™ System management Interface In-band Library
C
23
star
21

aocl-compression

A software library of lossless data compression methods tuned and optimized for AMD “Zen”-based CPUs
C
21
star
22

win-libm

Core Math functions for MS Windows
Assembly
20
star
23

openmm-hip

C
19
star
24

esmi_oob_library

for hosting E-SMI Out-of-band code
C
17
star
25

aocl-crypto

C++
15
star
26

Kria-RoboticsAI

Python
14
star
27

InfinityHub-CI

Dockerfile
12
star
28

go_amd_smi

C
10
star
29

scalapack

DEPRECATED. This Scalapck repository is deprecated. The last version in this repository is 3.0. Refer to "aocl-scalapack" repository under the same "amd" organization for AOCL Scalapack 3.1 release onwards. https://github.com/amd/aocl-scalapack
Fortran
9
star
30

GenAI-contest

Python
8
star
31

aocl-libmem

A library of AMD optimized memory and string functions
C
8
star
32

ZenDNN-onnxruntime

C++
7
star
33

sev-utils

Utilities and tools for AMD SEV memory encryption technologies
Shell
7
star
34

ama-sdk

HTML
7
star
35

aocl-utils

AOCL-Utils library to get CPU architecture, Cache information and CPU features flags etc.
C++
7
star
36

ZenDNN-pytorch

Python
5
star
37

ZenDNN-tensorflow-plugin

C++
5
star
38

Open-Field-Health-Check

Python
5
star
39

resource-optimizer

C
4
star
40

aocl-spack

DEPRECATED. This Spack repo is deprecated. Refer to "spack" repository under the same "amd" organization for AOCL Spack packages. https://github.com/amd/spack
Shell
3
star
41

ZenDNN-pytorch-plugin

Python
3
star
42

ZenDNN-tensorflow

C++
2
star
43

HPCTrainingDock

Shell
2
star
44

Linux_ISP_Kernel

C
2
star
45

mumps-build

CMake
1
star
46

tools-and-sdks

For distributing software via Spack tool
1
star
47

Linux_ISP_libcamera

C++
1
star