Initializing ONNX Runtime for vision encoder...
W rknn-toolkit-lite2 version: 2.3.2
W Query dynamic range failed. Ret code: RKNN_ERR_MODEL_INVALID. (If it is a static shape RKNN model, please ignore the above warning message.)
Vision encoder loaded successfully.
ONNX Input: pixel_values, ONNX Output: vision_features
Initializing RKLLM Runtime...
I rkllm: rkllm-runtime version: 1.2.1, rknpu driver version: 0.9.8, platform: RK3588
I rkllm: loading rkllm model from ./language_model_w8a8.rkllm
I rkllm: rkllm-toolkit version: 1.2.1, max_context_limit: 4096, npu_core_num: 3, target_platform: RK3588, model_dtype: W8A8
I rkllm: Enabled cpus: [4, 5, 6, 7]
I rkllm: Enabled cpus num: 4
I rkllm: Using mrope
RKLLM initialized successfully.
Preprocessing image...
Running vision encoder...
W The input[0] need NHWC data format, but NCHW set, the data format and data buffer will be changed to NHWC.
视觉编码器推理耗时: 3.5427 秒
Image encoded successfully.
I rkllm: reset chat template:
I rkllm: system_prompt: <|im_start|>system\nYou are a helpful assistant.<|im_end|>\n
I rkllm: prompt_prefix: <|im_start|>user\n
I rkllm: prompt_postfix: <|im_end|>\n<|im_start|>assistant\n
W rkllm: Calling rkllm_set_chat_template will disable the internal automatic chat template parsing, including enable_thinking. Make sure your custom prompt is complete and valid.
**********************可输入以下问题对应序号获取回答/或自定义输入********************
[0] Picture 1: <image> What is in the image?
[1] Picture 1: <image> 这张图片中有什么?
*************************************************************************
user: 0
Picture 1: <image> What is in the image?
robot: n_image_tokens: 289
The image shows a cozy bedroom with several notable features:
- A large bed covered with a blue comforter.
- A wooden dresser next to the bed, topped with various items including a mirror and some decorative objects.
- A window allowing natural light into the room, offering a view of greenery outside.
- A bookshelf filled with numerous books on shelves.
- A basket placed near the foot of the bed.
- A lamp on a side table beside the bed.
The overall ambiance is warm and inviting.
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Model init time (ms) 3361.48
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Stage Total Time (ms) Tokens Time per Token (ms) Tokens per Second
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Prefill 2201.45 321 6.86 145.81
I rkllm: Generate 12419.47 102 121.76 8.21
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Peak Memory Usage (GB)
I rkllm: 6.19
I rkllm: --------------------------------------------------------------------------------------
user: 1
Picture 1: <image> 这张图片中有什么?
robot: n_image_tokens: 289
这张照片展示了一个卧室的内部。房间有一扇大窗户,可以看到外面的绿色植物。房间里有各种物品:一个蓝色的大床单覆盖在一张床上;一盏灯放在梳妆台上;一面镜子挂在墙上;书架上摆满了书籍和一些装饰品;还有一些篮子、花盆和其他小物件散落在周围。
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Stage Total Time (ms) Tokens Time per Token (ms) Tokens per Second
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Prefill 184.35 13 14.18 70.52
I rkllm: Generate 8711.49 72 120.99 8.26
I rkllm: --------------------------------------------------------------------------------------
I rkllm: Peak Memory Usage (GB)
I rkllm: 6.19
I rkllm: --------------------------------------------------------------------------------------
Clone or download this repository locally. The model is large, so ensure you have enough disk space.
The RKNPU2 kernel driver version on your board must be >=0.9.6 to run such a large model. Run the following command with root privileges to check the driver version:
512: max_new_tokens, the maximum number of tokens to generate.
1024: max_context_len, the maximum context length.
3: npu_core_num, the number of NPU cores to use.
If the performance is not ideal, you can adjust the CPU scheduler to keep the CPU running at its highest frequency and bind the inference program to the big cores (taskset -c 4-7 python ...).
The example output is shown in the Chinese section above.
The vision encoder will be exported to vision/vision_encoder.onnx. The default height and width are 476, which you can modify using the --height and --width parameters.