RK182X Series CNN Inference (RK1828 Model)
Overall block diagram
Host (RK3588) RK1828 (PCIe AI coprocessor)
────────────────── ─────────────────────
test.jpg (224×224) 8-core NPU
│ │
▼ │
rknn3_cnn_demo -m -w -i -c 1 -cl 10 -mm │
│ │
▼ │
PCIe Gen3 x4 ──────────────────────────────► NPU inference (1 core)
-c(core_mask) must match the core count declared at model compile time, not the physical core count of the NPU: the NPU actually has 8 cores (RK1828 PCIe card,1d87:182a), MobileNet V2 declares 1 core at compile time (use-c 1), and Qwen3-1.7B declares 8 cores (use-c 0xff).The preinstalled mobilenet_v2 is FP16-only (for INT8, convert it yourself; see ch05 Model Conversion).
1. Prerequisites
# 1. RK182X NPU service healthy
systemctl is-active rknn3.service # → active
ls -l /dev/pcie-rkep-* # → /dev/pcie-rkep-0004:41:00.0
# 2. An RKNN model of MobileNet V2 (see ch05)Verification:
systemctl is-active rknn3.serviceOutput:
activels -l /dev/pcie-rkep-*Output:
crw------- 1 root root 10, 124 8月20日 16:56 /dev/pcie-rkep-0004:41:00.02. Deployed Models (FP16)
/userdata/RK1820_RK1828_AI_SDK/examples/gstreamer/MobilenetV2/
├── mobilenetv2-12.rknn 60,352 B # FP16 model structure
├── mobilenetv2-12.weight 7,037,440 B # FP16 model weights
├── labels.txt 21 KB # ImageNet 1000-class labels
└── config.json # Model configurationVerifying the files:
ls -la /userdata/RK1820_RK1828_AI_SDK/examples/gstreamer/MobilenetV2/Output:
-rw-r--r-- 1 linaro linaro 218 2026年 1月28日 config.json
-rw-r--r-- 1 linaro linaro 21675 2026年 1月28日 labels.txt
-rw-r--r-- 1 linaro linaro 60352 2026年 1月28日 mobilenetv2-12.rknn
-rw-r--r-- 1 linaro linaro 7037440 2026年 1月28日 mobilenetv2-12.weightFile sizes:
du -h /userdata/RK1820_RK1828_AI_SDK/examples/gstreamer/MobilenetV2/*.{rknn,weight}Output:
60K .../MobilenetV2/mobilenetv2-12.rknn
6.8M .../MobilenetV2/mobilenetv2-12.weight3. Inference Test (FP16, 1-core model with -c 1)
rknn3_cnn_demo \
-m /userdata/RK1820_RK1828_AI_SDK/examples/gstreamer/MobilenetV2/mobilenetv2-12.rknn \
-w /userdata/RK1820_RK1828_AI_SDK/examples/gstreamer/MobilenetV2/mobilenetv2-12.weight \
-i /rockchip-test/npu2/model/cat_224x224.jpg \
-c 1 \
-cl 10 \
-mmThe
-cvalue must match the core count declared at model compile time: MobileNet V2 declares 1 core →-c 1(verified working). A mismatch reportscore_mask X is not match with npu core number N!(N is the model's declared core count).
Tool help:
rknn3_cnn_demo --helpOutput:
Usage:
rknn3_cnn_demo [options]
Options:
-m, --model_path .rknn model path
-w, --weight_path .weight model path
-c, --core_mask core mask
-i, --image_path core mask
-cl, --cnt_loop default:1
-tl, --time_loop(hours)
-id, --device_id
--yuv input image is yuv420sp nv12
-mm, --enable_memory_monitor enable memory monitoring (default: disabled)Test image:
ls -la /rockchip-test/npu2/model/cat_224x224.jpgOutput:
-rwxr-xr-x 1 root root 58701 5月26日 09:09 /rockchip-test/npu2/model/cat_224x224.jpg4. Parameter Reference
| Parameter | Long option | Meaning |
|---|---|---|
-m | --model_path | RKNN model path |
-w | --weight_path | Weight path (mandatory for the API) |
-i | --image_path | Input image (224×224 JPG) |
-c | --core_mask | NPU core mask; must match the cores declared at compile time |
-cl | --cnt_loop | Loop count |
-id | --device_id | Device ID |
-mm | --enable_memory_monitor | Enable memory monitoring (requires root) |
5. Performance (1-core model with -c 1, average of 10 runs)
| RunCount | TotalTime | AvgFPS | AvgCost | AvgMemoryUsage | AvgNpuUtilization |
|---|---|---|---|---|---|
| 10 | 45.44 ms | 220.064 | 4.54 ms | unavailable | unavailable |
| Precision | Single inference | FPS | Model size |
|---|---|---|---|
| FP16 | 4.54 ms | 220 | 60KB + 6.8MB |
| INT8 | — | — | — |
-mmrequires root (non-root users get Permission denied); inference itself does not need root:sudo rknn3_cnn_demo ... -mm
6. Comparison: -c for CNN vs LLM
| Model type | Cores declared by model | Recommended -c |
|---|---|---|
| CNN (MobileNet V2) | 1 | 1 / 0x01 |
| LLM (Qwen3-1.7B) | 8 | 0xff |
7. Obtaining Other Precision Versions
# Download the ONNX source model
cd /userdata/RK1820_RK1828_AI_SDK/rknn/rknn3-model-zoo/examples/mobilenet_v2/model
bash download_model.sh
# → downloads mobilenetv2-12.onnx
# Convert to INT8 RKNN with rknn3-toolkit (see ch05)8. FAQ
| Symptom | Cause | Fix |
|---|---|---|
core_mask X is not match with npu core number N! | -c mismatched with model cores | MobileNetV2 uses -c 1, LLM uses -c 0xff |
Permission denied (with -mm) | Non-root user lacks permission | Add sudo |
rknn_load_model failed! ret=-2 | Model architecture mismatch | Confirm it is the RK1828 version (not RK356X/RK3588) |
weight_path is null or empty! | Missing -w parameter | Add -w <path>.weight |
9. Next Steps
- Model Conversion — convert to INT8 / other precisions
- LLM Inference — 8-core models (
-c 0xff) - NPU Overview — NPU hardware and drivers
