RKNN3 SDK provides the complete software stack for deploying AI models on RK1820/RK1828 coprocessors, including:
This repository provides a complete model deployment workflow:
| Model | Example Directory | Description |
|---|---|---|
| GLM-Edge | examples/glm_edge | GLM Edge series on-device LLM |
| MiniCPM5 | examples/MiniCPM5 | MiniCPM5 LLM |
| Nanbeige4.2 | examples/Nanbeige4_2 | Nanbeige Looped Transformer LLM |
| Qwen2.5 | examples/Qwen2_5 | Tongyi Qianwen 2.5 series LLM |
| Qwen3 | examples/Qwen3 | Tongyi Qianwen 3 series LLM |
| Qwen3.5 | examples/Qwen3_5 | Tongyi Qianwen 3.5 series LLM |
| FunctionGemma | examples/functiongemma | Google FunctionGemma function-calling model |
| LFM2.5 | examples/LFM2_5 | LiquidAI LFM2.5 hybrid-architecture LLM (Full Attention + streaming short convolution) |
| Model | Example Directory | Description |
|---|---|---|
| FastVLM | examples/FastVLM | Apple lightweight vision-language model |
| SmolVLM | examples/SmolVLM | HuggingFace lightweight vision-language model |
| SmolVLM2 | examples/SmolVLM2 | HuggingFace SmolVLM second-generation vision-language model |
| GME-Qwen2-VL | examples/GME-Qwen2-VL | Tongyi Qianwen vision embedding model |
| InternVLM | examples/InternVLM | InternVL vision-language model |
| Janus-Pro | examples/Janus_Pro | DeepSeek multimodal understanding and generation model |
| LocateAnything | examples/LocateAnything | NVIDIA visual grounding multimodal model (object detection / phrase grounding / GUI grounding) |
| MiniCPM-V-4 | examples/MiniCPM_V_4 | MiniCPM-V-4 vision-language model |
| Qwen2.5-VL | examples/Qwen2_5_VL | Tongyi Qianwen 2.5 vision-language model |
| Qwen3-VL | examples/Qwen3_VL | Tongyi Qianwen 3 vision-language model |
| Qwen3-VL-LoRA | examples/Qwen3_VL_LoRA | Tongyi Qianwen 3-VL LoRA fine-tuned model |
| Qwen3.5-VL | examples/Qwen3_5_VL | Tongyi Qianwen 3.5 vision-language model |
| UI-TARS | examples/UI_TARS | ByteDance GUI Agent vision-language model |
| Model | Example Directory | Description |
|---|---|---|
| Gemma-4 | examples/gemma4 | Google Gemma-4 multimodal model (text + audio) |
| Qwen2.5-Omni | examples/Qwen2_5_Omni | Tongyi Qianwen 2.5 omni model |
| Qwen3-Omni | Commercial closed-source model | Tongyi Qianwen 3 omni model |
| Qwen3.5-Omni | Commercial closed-source model | Tongyi Qianwen 3.5 omni model |
| Model | Example Directory | Description |
|---|---|---|
| Qwen3-ASR | examples/Qwen3_ASR | Tongyi Qianwen speech recognition (streaming / non-streaming) |
| SenseVoiceSmall | examples/sensevoice_small | Alibaba FunAudioLLM speech recognition model |
| WeNet (Conformer) | examples/wenet | WeNet U2++ Conformer streaming Chinese speech recognition |
| Whisper | examples/whisper | OpenAI multilingual speech recognition model |
| Zipformer | examples/zipformer | Zipformer streaming speech recognition |
| Model | Example Directory | Description |
|---|---|---|
| Qwen3-TTS | examples/Qwen3_TTS | Tongyi Qianwen text-to-speech |
| VITS | examples/vits | VITS speech synthesis (LJSpeech / VCTK) |
| Model | Example Directory | Description |
|---|---|---|
| Qwen3-Embedding | examples/Qwen3_Embedding | Tongyi Qianwen text embedding model |
| Qwen3-Reranker | examples/Qwen3_Reranker | Tongyi Qianwen reranker model |
| Model | Example Directory | Description |
|---|---|---|
| HY-MT1.5 | examples/HY_MT_1_5 | Hunyuan multilingual translation model |
| Model | Example Directory | Description |
|---|---|---|
| PaddleOCR-VL | examples/paddleocr_vl | Baidu PaddleOCR-VL visual OCR model |
| Model | Example Directory | Description |
|---|---|---|
| MobileNetV2 | examples/mobilenet_v2 | Lightweight image classification model |
| ResNet | examples/resnet | Classic residual image classification model |
| YOLOv5 | examples/yolov5 | Object detection model |
| YOLOv6 | examples/yolov6 | Object detection model |
| YOLOv8 | examples/yolov8 | Object detection model |
| YOLO26 | examples/yolo26 | Ultralytics YOLO26 object detection model (yolo26n/s/m) |
| YOLO26-Segment | examples/yolo26_segment | Ultralytics YOLO26 instance segmentation model |
| YOLO26-Pose | examples/yolo26_pose | Ultralytics YOLO26 human pose estimation model |
| QA-CLIP | examples/QAClip | Chinese-English image-text similarity model |
| Depth Anything V3 | examples/depth_anything_v3 | Multi-view stereo depth estimation model |
Users can download pre-converted RKNN models from the RKNN3_SDK cloud drive (access code: rknn). The models for this release are available under RKNN3_SDK/rknn3_models/v1.1.0.
| Host SoC | Coprocessor | OS |
|---|---|---|
| RK3588 Series | RK1820 / RK1828 | Linux / Android |
| RK3576 Series | RK1820 / RK1828 | Linux / Android |
| RK3572 Series | - | Linux / Android |
Build and runtime library notes:
- The top-level build scripts
build-linux.sh/build-android.shaccept-twithrk3588,rk3576,rk3572, andx86.- RKNN3 runtime libraries installed into each demo's
lib/directory are SoC-specific:
RK3588/RK3576:librknn3_api.soandlibrknn3_api_rkcp.soRK3572:librknn3_api.soandlibrknn3_api_native.so
Requirements: Python 3.10
cd rknn3_model_zoo/
pip install -r requirements.txt
export PYTHONPATH=./
All models follow a unified four-step flow: Export ONNX -> Convert RKNN -> Build -> Run.
# Step 1: Export ONNX model (--quant enables GRQ quantization)
cd examples/Qwen2_5/python/
python export_llm.py --quant
# Step 2: Convert to RKNN model
python export_rknn.py
# Step 3: Build
cd ../../../
export GCC_COMPILER=<GCC_COMPILER_PATH> # Optional: specify cross-compiler path
./build-linux.sh -t rk3588 -a aarch64 -d Qwen2_5
# Step 4: Push and run
adb push install/rk3588_linux_aarch64/rknn_Qwen2_5_demo/ /data/
adb shell
cd /data/rknn_Qwen2_5_demo
export LD_LIBRARY_PATH=./lib
./rknn_qwen2_5_demo \
model/Qwen2.5-0.5B-Instruct.rknn \
model/Qwen2.5-0.5B-Instruct.weight \
model/Qwen2.5-0.5B-Instruct.tokenizer.gguf \
model/Qwen2.5-0.5B-Instruct.embed.bin \
0xff \
"Who are you?"
# Step 1: Export ONNX models (Vision + LLM exported separately; --quant requires calibration data generated first)
cd examples/Qwen3_VL/python/llm/
python make_calidata.py --model_path Qwen/Qwen3-VL-4B-Instruct --modelscope
python export_llm.py --quant \
--model_path Qwen/Qwen3-VL-4B-Instruct \
--export_llm_path Qwen3-VL-4B-llm.onnx --modelscope
cd ../vision/
python make_calidata.py --model_path Qwen/Qwen3-VL-4B-Instruct --modelscope
python export_vision.py --quant \
--model_path Qwen/Qwen3-VL-4B-Instruct \
--export_vision_path Qwen3-VL-4B-vision.onnx --modelscope
# Step 2: Convert to RKNN models (Vision + LLM converted separately)
python export_rknn.py \
--onnx_path Qwen3-VL-4B-vision.onnx \
--rknn_path Qwen3-VL-4B-vision.rknn --platform rk1820 # Vision RKNN
cd ../llm/
python export_rknn.py \
--onnx_path Qwen3-VL-4B-llm.onnx \
--config Qwen3-VL-4B-llm.config.pkl \
--rknn_path Qwen3-VL-4B-llm.rknn --platform rk1820 # LLM RKNN
# Step 3: Build
cd ../../../
export GCC_COMPILER=<GCC_COMPILER_PATH> # Optional
./build-linux.sh -t rk3588 -a aarch64 -d Qwen3_VL
# Step 4: Push and run
adb push install/rk3588_linux_aarch64/rknn_Qwen3_VL_demo/ /data/
adb shell
cd /data/rknn_Qwen3_VL_demo
export LD_LIBRARY_PATH=./lib
./rknn_qwen3_vl_demo \
model/Qwen3-VL-4B-vision.rknn model/Qwen3-VL-4B-vision.weight \
model/Qwen3-VL-4B-llm.rknn model/Qwen3-VL-4B-llm.weight \
model/Qwen3-VL-4B-llm.tokenizer.gguf model/Qwen3-VL-4B-llm.embed.bin \
0xff 0xff \
model/demo.jpg \
"Please describe this image"
For model-specific parameters and differences, refer to the README in each example directory.
The export scripts of each model share the following common parameters (specific default values vary by model; see the README in each example directory):
| Parameter | Description |
|---|---|
--model_path | Model path or HuggingFace name |
--quant | Enable GRQ quantization algorithm (requires CUDA environment) |
--modelscope | Download model from ModelScope (recommended for China users) |
--export_llm_path / --export_vision_path | ONNX export path |
--platform / --target_platform | RKNN target platform (rk1820 / rk1828 / rk3572) |
--load_weight | Whether to load model weights (False exports structure only) |
Notes:
- When using GRQ quantization, the model contains quantization parameters; no quantization dataset is needed for RKNN conversion
- RKNN conversion uses weight-separated mode, generating both
.rknnand.weightfiles- LLM model export also includes Config (
.config.pkl), Tokenizer (.tokenizer.gguf), and Embed (.embed.bin) files
The Qwen2.5-VL and Qwen3-VL examples can link against the SpeedUP third-party library for inference acceleration.
Keep the following files in the release package:
3rdparty/SpeedUP/
├── include/speedup.h
├── Linux/aarch64/libSpeedUP.so
└── Android/arm64-v8a/libSpeedUP.so
# Qwen2.5-VL
./build-linux.sh -t rk3588 -a aarch64 -d Qwen2_5_VL
# Qwen3-VL
./build-linux.sh -t rk3588 -a aarch64 -d Qwen3_VL
After installation, libSpeedUP.so is copied into the corresponding demo lib/ directory.
./rknn_qwen2_5_vl_demo \ # or ./rknn_qwen3_vl_demo
<vision_model_path> <vision_weight_path> \
<llm_model_path> <llm_weight_path> \
<tokenizer_path> <embedding_path> \
<vision_core_mask> <llm_core_mask> \
<image_path> <prompt> \
[model_width model_height] [speedup_ratio]
speedup_ratio is optional:
| Value | Mode |
|---|---|
1.0 | Auto |
0.0 | Disabled |
(0.0, 1.0) | Manual |
For RKNN3 multi-core devices, this is usually suitable:
0xff 0xff
Qwen2.5-VL:
cd /userdata/rknn3-model-zoo/install/rk3588_linux_aarch64/rknn_Qwen2_5_VL_demo
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./rknn_qwen2_5_vl_demo \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-vision.rknn \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-vision.weight \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.rknn \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.weight \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.tokenizer.gguf \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.embed.bin \
0xff 0xff \
/userdata/rknn3-model-zoo/examples/Qwen2_5_VL/data/vision/demo.jpg \
"Describe this image" \
392 392 \
1.0
Qwen3-VL:
cd /userdata/rknn3-model-zoo/install/rk3588_linux_aarch64/rknn_Qwen3_VL_demo
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./rknn_qwen3_vl_demo \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-vision_384_384.rknn \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-vision_384_384.weight \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.rknn \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.weight \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.tokenizer.gguf \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.embed.bin \
0xff 0xff \
/userdata/rknn3-model-zoo/examples/Qwen2_5_VL/data/vision/demo.jpg \
"Describe this image" \
384 384 \
1.0
This example splits an LLM model into multiple segments (stages) at Transformer layer boundaries, with each segment deployed on one RK182X accelerator card. Through pipeline parallelism, it enables multi-card collaborative inference, supporting larger models and improving prefill performance.
Currently supported models:
| Model | RK182X Accelerator Cards |
|---|---|
Qwen/Qwen3.5-9B | 2 |
google/gemma-4-12B-it | 2 |
Qwen/Qwen3.5-27B | 4 |
Qwen/Qwen3.8-27B | 4 |
google/gemma-4-31B-it | 4 |
Segments are cut between layers without changing the intra-layer computation order; the last segment always contains the final norm and lm_head on top of its assigned Transformer layers. The export script does not simply split by total_layers / num_segments — it estimates each layer's weight (Transformer layers as W4A16/group32, lm_head as W6A16/group32, final norm as FP16) and automatically searches for balanced split boundaries so the estimated total weight of every segment is as close as possible. --num_segments N specifies the number of segments.
# Example: splitting Qwen3.5-9B into 2 segments
cd examples/multicard/python/qwen3_5
# Export segmented ONNX model
python export_llm_segment.py --model_path /path/to/Qwen3.5-9B --multi_segment --num_segments 2
# Export segmented RKNN model
python export_rknn_segment.py --multi_segment --num_segments 2
Qwen3.5 and Gemma-4 use an external rope cache by default. Each segment produces an identical .safetensors file; pass any one of them via --rope-tensor at runtime.
# Build
./build-linux.sh -t rk3588 -a aarch64 -d multicard
# Run (2-segment Qwen3.5-9B)
cd /data/rknn_multicard_demo
export LD_LIBRARY_PATH=./lib
taskset f0 ./rknn_multicard_demo \
--model /data/models/multicard/Qwen3.5-9B-llm_seg0.rknn \
--weight /data/models/multicard/Qwen3.5-9B-llm_seg0.weight \
--vocab /data/models/multicard/Qwen3.5-9B-llm.tokenizer.gguf \
--embed /data/models/multicard/Qwen3.5-9B-llm.embed.bin \
-c 4096 \
--core-mask 0xff \
--stage-count 2 \
--bucket-size 128 \
--rope-tensor /data/models/multicard/Qwen3.5-9B-llm_seg0.safetensors \
--prompt "<|im_start|>user\nHello<|im_end|>\n<|im_start|>assistant\n" \
--predict 128
Only the seg0 model/weight paths need to be passed; the paths of seg1..segN are derived automatically from the _segN suffix.
For complete parameter descriptions, Gemma-4 examples, KV Cache rebuild, and multi-card inference code logic, see
examples/multicard/README.md.
RKNN3 supports LoRA (Low-Rank Adaptation) adapter loading, which overlays LoRA weights onto the RKNN model without modifying the base model weights, enabling task-specific fine-tuned inference. Currently, Qwen3-VL is provided as an example.
LoRA weights (e.g., adapter_model.safetensors) do not need to be converted to ONNX separately; they can be passed directly to export_rknn.py:
cd examples/Qwen3_VL_LoRA/python/llm
# Export RKNN model with LoRA
python export_rknn.py \
--onnx_path Qwen3-VL-4B-llm.onnx \
--config Qwen3-VL-4B-llm.config.pkl \
--rknn_path Qwen3-VL-4B-llm-lora.rknn \
--lora_path /path/to/lora/adapter_model.safetensors \
--lora_config_path /path/to/lora/adapter_config.json
After export, two files are generated: .rknn and .lora_weight. Both must be provided during C++ inference.
# Build
./build-linux.sh -t rk3588 -a aarch64 -d Qwen3_VL_LoRA
# Run (Base + LoRA dual-path comparison)
cd /data/rknn_Qwen3_VL_LoRA_demo
export LD_LIBRARY_PATH=./lib
./rknn_qwen3_vl_demo \
./model/vision.rknn ./model/vision.weight \
./model/llm.rknn ./model/llm.weight \
./model/tokenizer.gguf ./model/embed.bin \
0x3 0x3 \
./model/demo.jpg "Describe this image" \
384 384 \
2048 3072 \
./model/llm_lora.weight
The program will sequentially output inference results and performance statistics for both the Base model and LoRA model.
| API | Description |
|---|---|
rknn3_lora_init(ctx, lora_weight_path) | Initialize LoRA environment from file |
rknn3_lora_load(ctx, lora) | Load LoRA adapter into context |
rknn3_session_enable_lora(session, lora) | Enable LoRA for the specified session (automatically clears kvcache) |
rknn3_session_disable_lora(session, lora) | Disable LoRA for the specified session |
rknn3_lora_unload(ctx, lora) | Unload LoRA adapter |
Recommended call sequence: lora_init -> query(LORA_NUM) -> query(LORA_INFO) -> lora_load -> session_enable_lora -> lora_unload
For complete parameter descriptions, API details, and dual-path inference implementation, see
examples/Qwen3_VL_LoRA/README.md.
Same-series Compatibility: Examples within the same model series are interchangeable. For instance, the Qwen2.5-0.5B example works directly with Qwen2.5-7B by simply changing the model loading path.
New Model Adaptation: For LLM models not included in this repository, refer to the LLM Model Adaptation Tutorial for ONNX export and deployment porting.
Transformers Version: Different models may require different transformers versions. Before exporting to ONNX, install the correct version. Version info can be found in the transformers_version field of the model's config.json (e.g., https://huggingface.co/Qwen/Qwen2.5-7B-Instruct/blob/main/config.json ). Some models have special version requirements; refer to the requirements.txt in each example directory.
PyTorch Version: Recommended PyTorch <= 2.8.0 (Qwen3-VL, Gemma-4, and other models require PyTorch >= 2.9.0; PaddleOCR-VL requires transformers == 4.55.0. See the requirements.txt under the corresponding model for details.)
Module Compatibility: Gemma-4 Audio and LLM models must use the same version (both E2B or both E4B); mixing versions is not supported.
This repository uses the following mirror sites by default to obtain model files:
C
48.3%
Python
36.0%
C++
10.3%
Shell
4.3%
CMake
1.0%
RKNN3 SDK provides the complete software stack for deploying AI models on RK1820/RK1828 coprocessors, including:
This repository provides a complete model deployment workflow:
| Model | Example Directory | Description |
|---|---|---|
| GLM-Edge | examples/glm_edge | GLM Edge series on-device LLM |
| MiniCPM5 | examples/MiniCPM5 | MiniCPM5 LLM |
| Nanbeige4.2 | examples/Nanbeige4_2 | Nanbeige Looped Transformer LLM |
| Qwen2.5 | examples/Qwen2_5 | Tongyi Qianwen 2.5 series LLM |
| Qwen3 | examples/Qwen3 | Tongyi Qianwen 3 series LLM |
| Qwen3.5 | examples/Qwen3_5 | Tongyi Qianwen 3.5 series LLM |
| FunctionGemma | examples/functiongemma | Google FunctionGemma function-calling model |
| LFM2.5 | examples/LFM2_5 | LiquidAI LFM2.5 hybrid-architecture LLM (Full Attention + streaming short convolution) |
| Model | Example Directory | Description |
|---|---|---|
| FastVLM | examples/FastVLM | Apple lightweight vision-language model |
| SmolVLM | examples/SmolVLM | HuggingFace lightweight vision-language model |
| SmolVLM2 | examples/SmolVLM2 | HuggingFace SmolVLM second-generation vision-language model |
| GME-Qwen2-VL | examples/GME-Qwen2-VL | Tongyi Qianwen vision embedding model |
| InternVLM | examples/InternVLM | InternVL vision-language model |
| Janus-Pro | examples/Janus_Pro | DeepSeek multimodal understanding and generation model |
| LocateAnything | examples/LocateAnything | NVIDIA visual grounding multimodal model (object detection / phrase grounding / GUI grounding) |
| MiniCPM-V-4 | examples/MiniCPM_V_4 | MiniCPM-V-4 vision-language model |
| Qwen2.5-VL | examples/Qwen2_5_VL | Tongyi Qianwen 2.5 vision-language model |
| Qwen3-VL | examples/Qwen3_VL | Tongyi Qianwen 3 vision-language model |
| Qwen3-VL-LoRA | examples/Qwen3_VL_LoRA | Tongyi Qianwen 3-VL LoRA fine-tuned model |
| Qwen3.5-VL | examples/Qwen3_5_VL | Tongyi Qianwen 3.5 vision-language model |
| UI-TARS | examples/UI_TARS | ByteDance GUI Agent vision-language model |
| Model | Example Directory | Description |
|---|---|---|
| Gemma-4 | examples/gemma4 | Google Gemma-4 multimodal model (text + audio) |
| Qwen2.5-Omni | examples/Qwen2_5_Omni | Tongyi Qianwen 2.5 omni model |
| Qwen3-Omni | Commercial closed-source model | Tongyi Qianwen 3 omni model |
| Qwen3.5-Omni | Commercial closed-source model | Tongyi Qianwen 3.5 omni model |
| Model | Example Directory | Description |
|---|---|---|
| Qwen3-ASR | examples/Qwen3_ASR | Tongyi Qianwen speech recognition (streaming / non-streaming) |
| SenseVoiceSmall | examples/sensevoice_small | Alibaba FunAudioLLM speech recognition model |
| WeNet (Conformer) | examples/wenet | WeNet U2++ Conformer streaming Chinese speech recognition |
| Whisper | examples/whisper | OpenAI multilingual speech recognition model |
| Zipformer | examples/zipformer | Zipformer streaming speech recognition |
| Model | Example Directory | Description |
|---|---|---|
| Qwen3-TTS | examples/Qwen3_TTS | Tongyi Qianwen text-to-speech |
| VITS | examples/vits | VITS speech synthesis (LJSpeech / VCTK) |
| Model | Example Directory | Description |
|---|---|---|
| Qwen3-Embedding | examples/Qwen3_Embedding | Tongyi Qianwen text embedding model |
| Qwen3-Reranker | examples/Qwen3_Reranker | Tongyi Qianwen reranker model |
| Model | Example Directory | Description |
|---|---|---|
| HY-MT1.5 | examples/HY_MT_1_5 | Hunyuan multilingual translation model |
| Model | Example Directory | Description |
|---|---|---|
| PaddleOCR-VL | examples/paddleocr_vl | Baidu PaddleOCR-VL visual OCR model |
| Model | Example Directory | Description |
|---|---|---|
| MobileNetV2 | examples/mobilenet_v2 | Lightweight image classification model |
| ResNet | examples/resnet | Classic residual image classification model |
| YOLOv5 | examples/yolov5 | Object detection model |
| YOLOv6 | examples/yolov6 | Object detection model |
| YOLOv8 | examples/yolov8 | Object detection model |
| YOLO26 | examples/yolo26 | Ultralytics YOLO26 object detection model (yolo26n/s/m) |
| YOLO26-Segment | examples/yolo26_segment | Ultralytics YOLO26 instance segmentation model |
| YOLO26-Pose | examples/yolo26_pose | Ultralytics YOLO26 human pose estimation model |
| QA-CLIP | examples/QAClip | Chinese-English image-text similarity model |
| Depth Anything V3 | examples/depth_anything_v3 | Multi-view stereo depth estimation model |
Users can download pre-converted RKNN models from the RKNN3_SDK cloud drive (access code: rknn). The models for this release are available under RKNN3_SDK/rknn3_models/v1.1.0.
| Host SoC | Coprocessor | OS |
|---|---|---|
| RK3588 Series | RK1820 / RK1828 | Linux / Android |
| RK3576 Series | RK1820 / RK1828 | Linux / Android |
| RK3572 Series | - | Linux / Android |
Build and runtime library notes:
- The top-level build scripts
build-linux.sh/build-android.shaccept-twithrk3588,rk3576,rk3572, andx86.- RKNN3 runtime libraries installed into each demo's
lib/directory are SoC-specific:
RK3588/RK3576:librknn3_api.soandlibrknn3_api_rkcp.soRK3572:librknn3_api.soandlibrknn3_api_native.so
Requirements: Python 3.10
cd rknn3_model_zoo/
pip install -r requirements.txt
export PYTHONPATH=./
All models follow a unified four-step flow: Export ONNX -> Convert RKNN -> Build -> Run.
# Step 1: Export ONNX model (--quant enables GRQ quantization)
cd examples/Qwen2_5/python/
python export_llm.py --quant
# Step 2: Convert to RKNN model
python export_rknn.py
# Step 3: Build
cd ../../../
export GCC_COMPILER=<GCC_COMPILER_PATH> # Optional: specify cross-compiler path
./build-linux.sh -t rk3588 -a aarch64 -d Qwen2_5
# Step 4: Push and run
adb push install/rk3588_linux_aarch64/rknn_Qwen2_5_demo/ /data/
adb shell
cd /data/rknn_Qwen2_5_demo
export LD_LIBRARY_PATH=./lib
./rknn_qwen2_5_demo \
model/Qwen2.5-0.5B-Instruct.rknn \
model/Qwen2.5-0.5B-Instruct.weight \
model/Qwen2.5-0.5B-Instruct.tokenizer.gguf \
model/Qwen2.5-0.5B-Instruct.embed.bin \
0xff \
"Who are you?"
# Step 1: Export ONNX models (Vision + LLM exported separately; --quant requires calibration data generated first)
cd examples/Qwen3_VL/python/llm/
python make_calidata.py --model_path Qwen/Qwen3-VL-4B-Instruct --modelscope
python export_llm.py --quant \
--model_path Qwen/Qwen3-VL-4B-Instruct \
--export_llm_path Qwen3-VL-4B-llm.onnx --modelscope
cd ../vision/
python make_calidata.py --model_path Qwen/Qwen3-VL-4B-Instruct --modelscope
python export_vision.py --quant \
--model_path Qwen/Qwen3-VL-4B-Instruct \
--export_vision_path Qwen3-VL-4B-vision.onnx --modelscope
# Step 2: Convert to RKNN models (Vision + LLM converted separately)
python export_rknn.py \
--onnx_path Qwen3-VL-4B-vision.onnx \
--rknn_path Qwen3-VL-4B-vision.rknn --platform rk1820 # Vision RKNN
cd ../llm/
python export_rknn.py \
--onnx_path Qwen3-VL-4B-llm.onnx \
--config Qwen3-VL-4B-llm.config.pkl \
--rknn_path Qwen3-VL-4B-llm.rknn --platform rk1820 # LLM RKNN
# Step 3: Build
cd ../../../
export GCC_COMPILER=<GCC_COMPILER_PATH> # Optional
./build-linux.sh -t rk3588 -a aarch64 -d Qwen3_VL
# Step 4: Push and run
adb push install/rk3588_linux_aarch64/rknn_Qwen3_VL_demo/ /data/
adb shell
cd /data/rknn_Qwen3_VL_demo
export LD_LIBRARY_PATH=./lib
./rknn_qwen3_vl_demo \
model/Qwen3-VL-4B-vision.rknn model/Qwen3-VL-4B-vision.weight \
model/Qwen3-VL-4B-llm.rknn model/Qwen3-VL-4B-llm.weight \
model/Qwen3-VL-4B-llm.tokenizer.gguf model/Qwen3-VL-4B-llm.embed.bin \
0xff 0xff \
model/demo.jpg \
"Please describe this image"
For model-specific parameters and differences, refer to the README in each example directory.
The export scripts of each model share the following common parameters (specific default values vary by model; see the README in each example directory):
| Parameter | Description |
|---|---|
--model_path | Model path or HuggingFace name |
--quant | Enable GRQ quantization algorithm (requires CUDA environment) |
--modelscope | Download model from ModelScope (recommended for China users) |
--export_llm_path / --export_vision_path | ONNX export path |
--platform / --target_platform | RKNN target platform (rk1820 / rk1828 / rk3572) |
--load_weight | Whether to load model weights (False exports structure only) |
Notes:
- When using GRQ quantization, the model contains quantization parameters; no quantization dataset is needed for RKNN conversion
- RKNN conversion uses weight-separated mode, generating both
.rknnand.weightfiles- LLM model export also includes Config (
.config.pkl), Tokenizer (.tokenizer.gguf), and Embed (.embed.bin) files
The Qwen2.5-VL and Qwen3-VL examples can link against the SpeedUP third-party library for inference acceleration.
Keep the following files in the release package:
3rdparty/SpeedUP/
├── include/speedup.h
├── Linux/aarch64/libSpeedUP.so
└── Android/arm64-v8a/libSpeedUP.so
# Qwen2.5-VL
./build-linux.sh -t rk3588 -a aarch64 -d Qwen2_5_VL
# Qwen3-VL
./build-linux.sh -t rk3588 -a aarch64 -d Qwen3_VL
After installation, libSpeedUP.so is copied into the corresponding demo lib/ directory.
./rknn_qwen2_5_vl_demo \ # or ./rknn_qwen3_vl_demo
<vision_model_path> <vision_weight_path> \
<llm_model_path> <llm_weight_path> \
<tokenizer_path> <embedding_path> \
<vision_core_mask> <llm_core_mask> \
<image_path> <prompt> \
[model_width model_height] [speedup_ratio]
speedup_ratio is optional:
| Value | Mode |
|---|---|
1.0 | Auto |
0.0 | Disabled |
(0.0, 1.0) | Manual |
For RKNN3 multi-core devices, this is usually suitable:
0xff 0xff
Qwen2.5-VL:
cd /userdata/rknn3-model-zoo/install/rk3588_linux_aarch64/rknn_Qwen2_5_VL_demo
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./rknn_qwen2_5_vl_demo \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-vision.rknn \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-vision.weight \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.rknn \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.weight \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.tokenizer.gguf \
/userdata/Qwen2.5-VL-3B/Qwen2.5-VL-3B-llm.embed.bin \
0xff 0xff \
/userdata/rknn3-model-zoo/examples/Qwen2_5_VL/data/vision/demo.jpg \
"Describe this image" \
392 392 \
1.0
Qwen3-VL:
cd /userdata/rknn3-model-zoo/install/rk3588_linux_aarch64/rknn_Qwen3_VL_demo
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./rknn_qwen3_vl_demo \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-vision_384_384.rknn \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-vision_384_384.weight \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.rknn \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.weight \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.tokenizer.gguf \
/userdata/Qwen3-VL-model/Qwen3-VL-4B-llm.embed.bin \
0xff 0xff \
/userdata/rknn3-model-zoo/examples/Qwen2_5_VL/data/vision/demo.jpg \
"Describe this image" \
384 384 \
1.0
This example splits an LLM model into multiple segments (stages) at Transformer layer boundaries, with each segment deployed on one RK182X accelerator card. Through pipeline parallelism, it enables multi-card collaborative inference, supporting larger models and improving prefill performance.
Currently supported models:
| Model | RK182X Accelerator Cards |
|---|---|
Qwen/Qwen3.5-9B | 2 |
google/gemma-4-12B-it | 2 |
Qwen/Qwen3.5-27B | 4 |
Qwen/Qwen3.8-27B | 4 |
google/gemma-4-31B-it | 4 |
Segments are cut between layers without changing the intra-layer computation order; the last segment always contains the final norm and lm_head on top of its assigned Transformer layers. The export script does not simply split by total_layers / num_segments — it estimates each layer's weight (Transformer layers as W4A16/group32, lm_head as W6A16/group32, final norm as FP16) and automatically searches for balanced split boundaries so the estimated total weight of every segment is as close as possible. --num_segments N specifies the number of segments.
# Example: splitting Qwen3.5-9B into 2 segments
cd examples/multicard/python/qwen3_5
# Export segmented ONNX model
python export_llm_segment.py --model_path /path/to/Qwen3.5-9B --multi_segment --num_segments 2
# Export segmented RKNN model
python export_rknn_segment.py --multi_segment --num_segments 2
Qwen3.5 and Gemma-4 use an external rope cache by default. Each segment produces an identical .safetensors file; pass any one of them via --rope-tensor at runtime.
# Build
./build-linux.sh -t rk3588 -a aarch64 -d multicard
# Run (2-segment Qwen3.5-9B)
cd /data/rknn_multicard_demo
export LD_LIBRARY_PATH=./lib
taskset f0 ./rknn_multicard_demo \
--model /data/models/multicard/Qwen3.5-9B-llm_seg0.rknn \
--weight /data/models/multicard/Qwen3.5-9B-llm_seg0.weight \
--vocab /data/models/multicard/Qwen3.5-9B-llm.tokenizer.gguf \
--embed /data/models/multicard/Qwen3.5-9B-llm.embed.bin \
-c 4096 \
--core-mask 0xff \
--stage-count 2 \
--bucket-size 128 \
--rope-tensor /data/models/multicard/Qwen3.5-9B-llm_seg0.safetensors \
--prompt "<|im_start|>user\nHello<|im_end|>\n<|im_start|>assistant\n" \
--predict 128
Only the seg0 model/weight paths need to be passed; the paths of seg1..segN are derived automatically from the _segN suffix.
For complete parameter descriptions, Gemma-4 examples, KV Cache rebuild, and multi-card inference code logic, see
examples/multicard/README.md.
RKNN3 supports LoRA (Low-Rank Adaptation) adapter loading, which overlays LoRA weights onto the RKNN model without modifying the base model weights, enabling task-specific fine-tuned inference. Currently, Qwen3-VL is provided as an example.
LoRA weights (e.g., adapter_model.safetensors) do not need to be converted to ONNX separately; they can be passed directly to export_rknn.py:
cd examples/Qwen3_VL_LoRA/python/llm
# Export RKNN model with LoRA
python export_rknn.py \
--onnx_path Qwen3-VL-4B-llm.onnx \
--config Qwen3-VL-4B-llm.config.pkl \
--rknn_path Qwen3-VL-4B-llm-lora.rknn \
--lora_path /path/to/lora/adapter_model.safetensors \
--lora_config_path /path/to/lora/adapter_config.json
After export, two files are generated: .rknn and .lora_weight. Both must be provided during C++ inference.
# Build
./build-linux.sh -t rk3588 -a aarch64 -d Qwen3_VL_LoRA
# Run (Base + LoRA dual-path comparison)
cd /data/rknn_Qwen3_VL_LoRA_demo
export LD_LIBRARY_PATH=./lib
./rknn_qwen3_vl_demo \
./model/vision.rknn ./model/vision.weight \
./model/llm.rknn ./model/llm.weight \
./model/tokenizer.gguf ./model/embed.bin \
0x3 0x3 \
./model/demo.jpg "Describe this image" \
384 384 \
2048 3072 \
./model/llm_lora.weight
The program will sequentially output inference results and performance statistics for both the Base model and LoRA model.
| API | Description |
|---|---|
rknn3_lora_init(ctx, lora_weight_path) | Initialize LoRA environment from file |
rknn3_lora_load(ctx, lora) | Load LoRA adapter into context |
rknn3_session_enable_lora(session, lora) | Enable LoRA for the specified session (automatically clears kvcache) |
rknn3_session_disable_lora(session, lora) | Disable LoRA for the specified session |
rknn3_lora_unload(ctx, lora) | Unload LoRA adapter |
Recommended call sequence: lora_init -> query(LORA_NUM) -> query(LORA_INFO) -> lora_load -> session_enable_lora -> lora_unload
For complete parameter descriptions, API details, and dual-path inference implementation, see
examples/Qwen3_VL_LoRA/README.md.
Same-series Compatibility: Examples within the same model series are interchangeable. For instance, the Qwen2.5-0.5B example works directly with Qwen2.5-7B by simply changing the model loading path.
New Model Adaptation: For LLM models not included in this repository, refer to the LLM Model Adaptation Tutorial for ONNX export and deployment porting.
Transformers Version: Different models may require different transformers versions. Before exporting to ONNX, install the correct version. Version info can be found in the transformers_version field of the model's config.json (e.g., https://huggingface.co/Qwen/Qwen2.5-7B-Instruct/blob/main/config.json ). Some models have special version requirements; refer to the requirements.txt in each example directory.
PyTorch Version: Recommended PyTorch <= 2.8.0 (Qwen3-VL, Gemma-4, and other models require PyTorch >= 2.9.0; PaddleOCR-VL requires transformers == 4.55.0. See the requirements.txt under the corresponding model for details.)
Module Compatibility: Gemma-4 Audio and LLM models must use the same version (both E2B or both E4B); mixing versions is not supported.
This repository uses the following mirror sites by default to obtain model files:
C
48.3%
Python
36.0%
C++
10.3%
Shell
4.3%
CMake
1.0%