how to convert onnx into an rknn model?
ouxiand opened this issue · 8 comments
Hello, Thank you for sharing such a great project!
May I ask how to convert onnx into an rknn model?I want to run this lightglue onnx model on rknn npu.
However, rknn does not support dynamic calls and has no idea at all.
Who knows how to solve it?
you can set the shape of the model to static shape
Input/Output has been set to 512,but there were some errors:
root@6ddf679dd88b:/examples# python onnx2rknn.py
W init: rknn-toolkit2 version: 1.6.0+81f21f4d
W config: Please make sure the model can be dynamic when enable 'config.dynamic_input'!
W config: The 'dynamic_input' function has been enabled, the MaxShape is dynamic_input[0] = [[1, 3, 512, 512]]!
The following functions are subject to the MaxShape:
1. The quantified dataset needs to be configured according to MaxShape
2. The eval_perf or eval_memory return the results of MaxShape
--> Loading model
W load_onnx: It is recommended onnx opset 19, but your onnx model opset is 17!
W load_onnx: Model converted from pytorch, 'opset_version' should be set 19 in torch.onnx.export for successful convert!
Loading : 100%|████████████████████████████████████████████████| 125/125 [00:00<00:00, 94228.61it/s]
done
--> Building model
E build: The input 0 of NonZero('/NonZero') need to be constant! It will cause the graph to be a dynamic graph!
Remove NonZero('/NonZero') manually and try again!
W build: ===================== WARN(5) =====================
E rknn-toolkit2 version: 1.6.0+81f21f4d
E build: Catch exception when building RKNN model!
E build: Traceback (most recent call last):
E build: File "rknn/api/rknn_base.py", line 1971, in rknn.api.rknn_base.RKNNBase.build
E build: File "rknn/api/graph_optimizer.py", line 779, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
E build: File "rknn/api/graph_optimizer.py", line 347, in rknn.api.graph_optimizer._dynamic_check
E build: File "rknn/api/rknn_log.py", line 92, in rknn.api.rknn_log.RKNNLog.e
E build: ValueError: The input 0 of NonZero('/NonZero') need to be constant! It will cause the graph to be a dynamic graph!
E build: Remove NonZero('/NonZero') manually and try again!
W If you can't handle this error, please try updating to the latest version of the toolkit2 and runtime from:
https://console.zbox.filez.com/l/I00fc3 (Pwd: rknn) Path: RKNPU2_SDK / 1.X.X / develop /
If the error still exists in the latest version, please collect the corresponding error logs and the model,
convert script, and input data that can reproduce the problem, and then submit an issue on:
https://redmine.rock-chips.com (Please consult our sales or FAE for the redmine account)
build model failed.
Cannot use NPU model, can only use CPU, slow speed, currently no better solution.
Same problem with simple model from torchhub model zoo
anyone found the solution?
anyone found the solution?
You should write an implementation of the NonZero operation. The documentation contains a description of how to do this.
anyone found the solution?
You should write an implementation of the NonZero operation. The documentation contains a description of how to do this.
which documentation you refered to, could you please provide it?