Linux Installation Instructions#
Ryzen AI for Linux supports running AI models on the AMD Neural Processing Unit (NPU). Linux support is available on newer consumer APUs, beginning with Strix Point, and on newer embedded APUs, beginning with Ryzen™ AI Embedded P100.
With this release, users can now compile and run AI models using the following formats:
CNN models in INT8
CNN models in BF16
NLP models (e.g., BERT, encoder-based) in BF16
LLMs (NPU-only flow)
Prerequisites#
Dependencies |
Version Requirement |
|---|---|
Ubuntu Distribution |
Ubuntu 24.04 LTS |
Kernel Version |
>= 6.10 |
RAM |
64 GB (Recommended) |
Python |
3.12.x |
Use the commands below to install Python 3.12.x along with certain dependencies
sudo apt update
sudo apt install python3.12
sudo apt install python3.12-venv
sudo apt install libboost-filesystem1.74.0
sudo apt install dkms
After installing required Ubuntu distribution and Python version, proceed with NPU drivers installation
Install NPU Drivers#
Download the NPU driver package from Ryzen AI Linux Drivers.
- RyzenAI linux driver package contains
- XRT Package
xrt_202620.2.26.89_24.04-amd64-base.deb
xrt_202620.2.26.89_24.04-amd64-base-dev.deb
xrt_202620.2.26.89_24.04-amd64-npu.deb
- NPU driver package
xrt_plugin.2.26.260102.59.release_24.04-amd64-amdxdna.deb
Install NPU driver package on your machine
sudo apt install --fix-broken -y ./xrt_202620.2.26.89_24.04-amd64-base.deb
sudo apt install --fix-broken -y ./xrt_202620.2.26.89_24.04-amd64-base-dev.deb
sudo apt install --fix-broken -y ./xrt_202620.2.26.89_24.04-amd64-npu.deb
sudo apt install --fix-broken -y ./xrt_plugin.2.26.260102.59.release_24.04-amd64-amdxdna.deb
Verify your Driver installation
source /opt/xilinx/xrt/setup.sh
xrt-smi examine
Device(s) Present
|BDF |Name |Architecture |Topology |
|----------------|--------------------|--------------|----------|
|[0000:c5:00.1] |NPU Strix |aie2p |6x8 |
# NPU name and Device code may differ based on your machine
Install Ryzen AI Software#
Download the RyzenAI for Linux package ryzen_ai-1.9.0.tgz from Ryzen AI Software Installer.
Navigate to the downloaded path and follow the below steps
mkdir ryzen_ai-1.9.0
mv ryzen_ai-1.9.0.tgz ryzen_ai-1.9.0
cd ryzen_ai-1.9.0
tar -xvzf ryzen_ai-1.9.0.tgz
Install RyzenAI package at your desired target path
./install_ryzen_ai.sh -a yes -p <TARGET-PATH>/venv
source <TARGET-PATH>/venv/bin/activate
This will successfully install RyzenAI and activate the Virtual environment at your target location
# Validate your installation path
echo $RYZEN_AI_INSTALLATION_PATH
Set essential Environment variables
export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:${RYZEN_AI_INSTALLATION_PATH}/onnxruntime/lib/:$LD_LIBRARY_PATH
Note#
Moving forward, Linux Installation will transition from *.tgz to *.deb based Installer.
In RyzenAI 1.9 release, we are providing this optional method as a preview.
- Related files
Download ryzen-ai-runtime_1.9.0-1_amd64.deb from Ryzen AI (deb) Software Installer.
Download setup_ryzen_ai.sh from Ryzen AI Setup script.
Installation Instructions
chmod +x setup_ryzen_ai.sh
./setup_ryzen_ai.sh -a yes -d ./ryzen-ai-runtime_1.9.0-1_amd64.deb -p <TARGET-PATH>/venv
# -p <path> (default: ~/ryzen-ai-venv)
source <TARGET-PATH>/venv/bin/activate
# Deb installation defaults to /opt in the disk.
# If there is memory shortage, redirect Installation using below flag
# ./setup_ryzen_ai.sh -a yes -d ./ryzen-ai-runtime_1.9.0-1_amd64.deb -p <TARGET-PATH>/venv -c "$HOME/ryzen-ai-runtime"
Test the Installation#
The RyzenAI software package contains a test script that verifies your correct installation of NPU Drivers.
Navigate to your targeted Virtual Environment created in the previous step
You will observe a subfolder named “quicktest”
cd <TARGET-PATH>/venv/quicktest
python quicktest.py
The quicktest.py script picks up a simple CNN model, compiles it and runs on AMD’s Neural Processing Unit (NPU).
On successful run, you can observe output as shown below.
Setting environment for STX/KRK
[I:onnxruntime:, compile_pass_manager.cpp:1680 compile_pass_manager.cpp] Compile done.
[I:onnxruntime:, stat.cpp:198 stat.cpp] [Vitis AI EP] No. of Operators :
[I:onnxruntime:, stat.cpp:198 stat.cpp] NPU 398
[I:onnxruntime:, stat.cpp:198 stat.cpp] VITIS_EP_CPU 2
[I:onnxruntime:, stat.cpp:198 stat.cpp]
[I:onnxruntime:, stat.cpp:198 stat.cpp] [Vitis AI EP] No. of Subgraphs :
[I:onnxruntime:, stat.cpp:198 stat.cpp] NPU 1
[I:onnxruntime:, stat.cpp:198 stat.cpp] Actually running on NPU 1
Test Finished
Examples, Demos, Tutorials#
RyzenAI-SW demonstrates various demos and examples for Model compilation and deployment on NPUs
- Here are a few examples from our RyzenAI Software Repository
Note#
- Before running the above examples -
RyzenAI-SW repo hosts a diverse set of examples with both NPU and iGPU Execution Provider. However, Linux currently supports NPU only flow.
RyzenAI creates its own Python Virtual Environment to run the examples. Skip Windows-specific Python virtual environment activation instructions
Ensure to activate Linux based Python Virtual Environment
source <TARGET-PATH>/venv/bin/activate
Get NPU Info for your Machine#
Getting started Resnet with INT8 Model
Getting started Resnet with INT8 Model contains Resnet_util.py script that has a function “get_npu_info” to detect correct “NPU type” in your machine. This NPU lookup logic is based for Windows system.
For Linux, NPU lookup logic is shown below:
import subprocess
def get_npu_info():
# Run below command as subprocess to enumerate PCI devices
command = r'lspci -nn'
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
# Check for supported Hardware IDs
npu_type = ''
if '1022:17f0' in stdout.decode(): npu_type = 'STX/KRK'
return npu_type
Running LLM#
Follow this page to run LLM models on Linux: Running LLM on Linux