Converting Model Successful yet I get: Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
Hi there, I am currently trying to convert my yolov3-tiny (.pb or .tflite) model to perform inference on my tinker board R with the following code:
rknn = RKNN(verbose=True,verbose_file="./verbose_log")
INPUT_NODE=["self"]
OUTPUT_NODE=["functional_1/tf_op_layer_concat_6/concat_6", "functional_1/tf_op_layer_concat_3/concat_3"]
rknn.config(
quantized_dtype="asymmetric_quantized-u8",
batch_size=1,
target_platform="rk3399pro"
)
ret = rknn.load_tensorflow(tf_pb="yolo_relu_frozen_model.pb",
inputs=INPUT_NODE,
outputs=OUTPUT_NODE,
input_size_list=[[416,416,3]]
)
if ret != 0:
print("load failed")
exit(ret)
ret = rknn.build(do_quantization=True, pre_compile=False, dataset="./quantize/rknn/dataset.txt")
if ret !=0:
print("build failed")
exit(ret)
name += "_quantized_rknn"
ret = rknn.export_rknn("yolo_relu_quantized_rknn.rknn")
if ret != 0:
print("export failed!")
exit(ret)
Inside dataset.txt I got correct path to 500 images which are also used for quantization, as I can tell from logging output:
....
D 250(50.20%), Queue size 1
D 251(50.40%), Queue size 1
D 252(50.60%), Queue size 1
D 253(50.80%), Queue size 1
D 254(51.00%), Queue size 1
D 255(51.20%), Queue size 1
....
At the end it says I Build config finished.
Conversion looks good right?
But when I try to initialize it I get the error "Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID"
from rknn.api import RKNN
self.model = RKNN()
ret = self.model.load_rknn("yolo_relu_quantized_rknn.rknn"), load_model_in_npu=True)
print(ret) #prints 0
ret = self.model.init_runtime(device_id="9bb09d3aee19a1d2")
print(ret) #prints -1
The error is:
I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0 (b5861e7@2020-11-23T11:50:51)
I NPUTransfer: Starting NPU Transfer Client, Transfer version 2.1.0 (b5861e7@2020-11-23T11:50:51)
E RKNNAPI: rknn_init, msg_load_ack fail, ack = 1(ACK_FAIL), expect 0(ACK_SUCC)!
E RKNNAPI: ==============================================
E RKNNAPI: RKNN VERSION:
E RKNNAPI: API: 1.7.0 (f75fb8e build: 2021-07-21 08:53:08)
E RKNNAPI: DRV: 1.3.1 (6ebb4d7 build: 2020-01-02 09:37:58)
E RKNNAPI: ==============================================
E Catch exception when init runtime!
E Traceback (most recent call last):
E File "rknn/api/rknn_base.py", line 884, in rknn.api.rknn_base.RKNNBase.init_runtime
E File "rknn/api/rknn_runtime.py", line 341, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
E Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
Can someone help here please? I haven't found any guide on how to proceed here
It's possibly that your driver on board is too low, which is : E RKNNAPI: DRV: 1.3.1 (6ebb4d7 build: 2020-01-02 09:37:58)
You can get the new driver here: https://github.com/rockchip-linux/rknpu/tree/master/drivers step1: choose your platform and push the folder to the root on board. step2: chosse your platfrom .ko file in <npu_ko> folder and push it to the board. You should can use command 'find -name galcore.ko' to find where it is. step3: reboot your board.
Hi @zen-xingle thank you for your help, I am using the tinker edge R, which is arm64. I have placed the contents from /drivers/linux-aarch64 to /
I can't seem to find any galcore.ko files on my board tho?
When I execute find -name '*.ko' in / I get the following output:
./system/lib/modules/bcmdhd.ko
./system/lib/modules/8822ce.ko
./system/lib/modules/8822be.ko
./system/lib/modules/8188eu.ko
Got any pointers to where that .ko file might be?
Hi @zen-xingle one more question I tried to init the runtime with my generated rknn model locally on the simulator, and I get the same error:
librknn_runtime version 1.7.0 (9ad5c07 build: 2021-08-06 15:20:31 base: 1131)
E [compute_node:354]Create node[0] NBG fail
Create rknn graph fail!
Create RKNN model fail, error=-6
E Catch exception when init runtime!
E Traceback (most recent call last):
E File "rknn/api/rknn_base.py", line 884, in rknn.api.rknn_base.RKNNBase.init_runtime
E File "rknn/api/rknn_runtime.py", line 341, in rknn.api.rknn_runtime.RKNNRuntime.build_graph
E Exception: RKNN init failed. error code: RKNN_ERR_MODEL_INVALID
-1
Is it possible for my model to be not compatible with rknn? Or am I doing the conversion wrong?
Hi @lukqw
Searching for tinker edge R, I thought it is based on RK3399pro chip. And for 3399pro platform, it's actually a little bit different to update the driver comparing to RK1808 or RV1109. You may need to ask their tech-support how to update your driver.
For the second question, searching '-6' in https://github.com/rockchip-linux/rknn-toolkit/blob/master/doc/Rockchip_Trouble_Shooting_RKNN_Toolkit_V1.7.0_EN.pdf. There are some reason that may lead to this error. Also there is a yolov3 demo here https://github.com/rockchip-linux/rknn-toolkit/tree/master/examples/darknet/yolov3.
For yolo-type model, it's better to use yolov5 on RKNN NPU platform. For the inference time, you can check here https://github.com/EASY-EAI/yolov5. For the yolov5 convert here demo, you can check here https://github.com/rockchip-linux/rknn-toolkit/tree/master/examples/onnx/yolov5. For the yolov5 deployment C++ demo, you can check here https://github.com/rockchip-linux/rknpu/tree/master/rknn/rknn_api/examples/rknn_yolov5_demo.
hi @lukqw you solve it?
@Islam1Samir sadly not
I have same issue. Please help us.