Change NPU frequency on Radxa Zero 3W

Hi everyone!

My question is: How to change NPU frequency on Radxa Zero 3W/E board?

I’ve search the forum for clues, and the only one I got is /sys/class/devfreq/fde40000.npu/userspace/set_freq, but my image (https://github.com/radxa-build/radxa-zero3/releases/download/b6/radxa-zero3_debian_bullseye_xfce_b6.img.xz) does not have this file and userspace folder at all.

Could someone please provide a method for changing NPU frequency?

My current NPU freq value is too low:

root@radxa-zero3:/sys/class/devfreq/fde40000.npu# cat cur_freq
0
root@radxa-zero3:/sys/class/devfreq/fde40000.npu# cat max_freq
900000000
root@radxa-zero3:/sys/class/devfreq/fde40000.npu# cat min_freq
200000000

Despite the fact that cur_freq = 0 I can do inference with RKNN-Toolkit2:

(rknn2_env_39) radxa@radxa-zero3:~/rknn-toolkit2/rknn-toolkit-lite2/examples/resnet18$ python test.py
W rknn-toolkit-lite2 version: 2.1.0
--> Load RKNN model
done
--> Init runtime environment
I RKNN: [10:59:44.126] RKNN Runtime Information, librknnrt version: 1.6.0 (9a7b5d24c@2023-12-13T17:31:11)
I RKNN: [10:59:44.127] RKNN Driver Information, version: 0.8.8
I RKNN: [10:59:44.128] RKNN Model Information, version: 6, toolkit version: 2.1.0+708089d1(compiler version: 2.1.0 (967d001cc8@2024-08-07T11:32:45)), target: RKNPU lite, target platform: rk3566, framework name: PyTorch, framework layout: NCHW, model inference type: static_shape
W RKNN: [10:59:44.128] RKNN Model version: 2.1.0 not match with rknn runtime version: 1.6.0
W RKNN: [10:59:44.186] query RKNN_QUERY_INPUT_DYNAMIC_RANGE error, rknn model is static shape type, please export rknn with dynamic_shapes
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.)
done
--> Running model
resnet18
-----TOP 5-----
[812] score:0.999680 class:"space shuttle"
[404] score:0.000249 class:"airliner"
[657] score:0.000013 class:"missile"
[466] score:0.000009 class:"bullet train, bullet"
[895] score:0.000008 class:"warplane, military plane"

done

you can change the freq like this

echo userspace > /sys/class/devfreq/fde40000.npu/governor
echo 900000000 > /sys/class/devfreq/fde40000.npu/userspace/set_freq

1 Like

Thanks!

NPU frequency changed and now my inference speed is faster by 30% on my custom (but not working) yolov5n model.

But, after the reboot userspace governor is replaced with rknpu_ondemand. How can I make those changes persistent between reboots? Could it be fixed with some kind of a service which starts just after the boot process?

Could it be fixed with some kind of a service which starts just after the boot process?
yes, you can write a service for that.

1 Like