PaddlePaddle / FastDeploy

⚡️An Easy-to-use and Fast Deep Learning Model Deployment Toolkit for ☁️Cloud 📱Mobile and 📹Edge. Including Image, Video, Text and Audio 20+ main stream scenarios and 150+ SOTA models with end-to-end optimization, multi-platform and multi-framework support.
https://www.paddlepaddle.org.cn/fastdeploy
Apache License 2.0
2.99k stars 465 forks source link

RK3568平台上进行PP-OCR模型部署出现推理失败的问题 #1770

Closed MrMzl closed 1 year ago

MrMzl commented 1 year ago

环境

报错内容

firefly@firefly:~/FastDeploy_RK3568/FastDeploy/examples/vision/ocr/PP-OCR/rockchip/cpp/build$ ./infer_demo ./ch_PP-OCRv3_det_infer/ch_PP-OCRv3_det_infer.onnx ./ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.onnx ./ch_PP-OCRv3_rec_infer/ch_PP-OCRv3_rec_infer.onnx ./ppocr_keys_v1.txt ./12.jpg 1 E RKNN: [02:14:42.649] parseRKNN: invalid RKNN_MAGIC! E RKNN: [02:14:42.649] parseRKNN from path: Invalid RKNN format! E RKNN: [02:14:42.649] rknn_init, load model failed! [ERROR] fastdeploy/runtime/backends/rknpu2/rknpu2_backend.cc(157)::LoadModel rknn_init fail! ret=-6 [ERROR] fastdeploy/runtime/backends/rknpu2/rknpu2_backend.cc(100)::Init load model failed [ERROR] fastdeploy/runtime/runtime.cc(328)::CreateRKNPU2Backend Failed to initialize RKNPU2 backend. Aborted

PC端onnx转rknn模型环境

【Package 】【 Version】 absl-py 0.15.0 astunparse 1.6.3 cached-property 1.5.2 cachetools 4.2.4 certifi 2020.6.20 charset-normalizer 2.0.12 clang 5.0 dataclasses 0.8 fast-histogram 0.11 flatbuffers 1.12 gast 0.4.0 google-auth 1.35.0 google-auth-oauthlib 0.4.6 google-pasta 0.2.0 grpcio 1.48.2 h5py 3.1.0 idna 3.4 importlib-metadata 4.8.3 importlib-resources 5.4.0 keras 2.6.0 Keras-Preprocessing 1.1.2 Markdown 3.3.7 numpy 1.19.5 oauthlib 3.2.2 onnx 1.10.0 onnxoptimizer 0.2.7 onnxruntime 1.10.0 opencv-python 4.5.5.64 opt-einsum 3.3.0 paddle2onnx 1.0.6 Pillow 8.4.0 pip 21.3.1 protobuf 3.12.2 psutil 5.9.0 pyasn1 0.4.8 pyasn1-modules 0.2.8 PyYAML 6.0 requests 2.27.1 requests-oauthlib 1.3.1 rknn-toolkit2 1.4.3b4+48391b8f rsa 4.9 ruamel.yaml 0.17.4 ruamel.yaml.clib 0.2.7 scipy 1.5.4 setuptools 59.6.0 six 1.15.0 tensorboard 2.6.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow 2.6.2 tensorflow-estimator 2.6.0 termcolor 1.1.0 torch 1.10.1 torchvision 0.11.2 tqdm 4.64.0 typing-extensions 3.7.4.3 urllib3 1.26.15 Werkzeug 2.0.3 wheel 0.37.1 wrapt 1.12.1 zipp 3.6.0

模型转换操作流程

export_log.txt

板端环境编译流程

在PC端完成交叉编译后在板端进入下面路径下进行编译

firefly@firefly:~/FastDeploy_RK3568/FastDeploy/examples/vision/ocr/PP-OCR/rockchip/cpp/build$ cmake .. -DFASTDEPLOY_INSTALL_DIR=~/FastDeploy_RK3568/FastDeploy/build/fastdeploy-0.0.0 -- The C compiler identification is GNU 8.3.0 -- The CXX compiler identification is GNU 8.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- The path of RKNPU2 is /home/firefly/FastDeploy_RK3568/FastDeploy/build/fastdeploy-0.0.0/third_libs/install/rknpu2_runtime/lib/librknnrt.so. -- The path of OpenCV is /home/firefly/FastDeploy_RK3568/FastDeploy/build/fastdeploy-0.0.0/third_libs/install/opencv. -- Found OpenCV: /home/firefly/FastDeploy_RK3568/FastDeploy/build/fastdeploy-0.0.0/third_libs/install/opencv (found version "4.6.0") -- -- *****FastDeploy Building Summary** -- CMake version : 3.13.4 -- CMake command : /usr/bin/cmake -- System : Linux -- C++ compiler : /usr/bin/c++ -- C++ compiler version : 8.3.0 -- CXX flags : -Wno-format -- EXE linker flags : -- Shared linker flags : -- Build type : -- Compile definitions : _GLIBCXX_USE_CXX11_ABI=1 -- CMAKE_PREFIX_PATH : -- CMAKE_INSTALL_PREFIX : /usr/local -- CMAKE_MODULE_PATH : -- -- FastDeploy version : 0.0.0 -- ENABLE_ORT_BACKEND : OFF -- ENABLE_RKNPU2_BACKEND : ON -- ENABLE_SOPHGO_BACKEND : OFF -- ENABLE_PADDLE_BACKEND : OFF -- ENABLE_LITE_BACKEND : OFF -- ENABLE_POROS_BACKEND : OFF -- ENABLE_TRT_BACKEND : OFF -- ENABLE_OPENVINO_BACKEND : OFF -- ENABLE_BENCHMARK : OFF -- ENABLE_VISION : ON -- ENABLE_TEXT : OFF -- ENABLE_ENCRYPTION : OFF -- ENABLE_FLYCV : OFF -- ENABLE_CVCUDA : OFF -- WITH_GPU : OFF -- WITH_IPU : OFF -- WITH_TESTING : OFF -- WITH_ASCEND : OFF -- WITH_DIRECTML : OFF -- WITH_TIMVX : OFF -- WITH_KUNLUNXIN : OFF -- WITH_CAPI : OFF -- WITH_CSHARPAPI : OFF -- DEPENDENCY_LIBS : /home/firefly/FastDeploy_RK3568/FastDeploy/build/fastdeploy-0.0.0/lib/libfastdeploy.so;/home/firefly/FastDeploy_RK3568/FastDeploy/build/fastdeploy-0.0.0/third_libs/install/rknpu2_runtime/lib/librknnrt.so;opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio -- Configuring done -- Generating done -- Build files have been written to: /home/firefly/FastDeploy_RK3568/FastDeploy/examples/vision/ocr/PP-OCR/rockchip/cpp/build firefly@firefly:~/FastDeploy_RK3568/FastDeploy/examples/vision/ocr/PP-OCR/rockchip/cpp/build$ make -j Scanning dependencies of target infer_demo [ 50%] Building CXX object CMakeFiles/infer_demo.dir/infer.cc.o [100%] Linking CXX executable infer_demo [100%] Built target infer_demo firefly@firefly:~/FastDeploy_RK3568/FastDeploy/examples/vision/ocr/PP-OCR/rockchip/cpp/build$ ls CMakeCache.txt CMakeFiles Makefile cmake_install.cmake infer_demo

板端推理操作流程

firefly@firefly:~/FastDeploy_RK3568/FastDeploy/examples/vision/ocr/PP-OCR/rockchip/cpp/build$ ./infer_demo ./ch_PP-OCRv3_det_infer/ch_PP-OCRv3_det_infer.onnx ./ch_ppocr_mobile_v2.0_cls_infer/ch_ppocr_mobile_v2.0_cls_infer.onnx ./ch_PP-OCRv3_rec_infer/ch_PP-OCRv3_rec_infer.onnx ./ppocr_keys_v1.txt ./12.jpg 1 E RKNN: [02:14:42.649] parseRKNN: invalid RKNN_MAGIC! E RKNN: [02:14:42.649] parseRKNN from path: Invalid RKNN format! E RKNN: [02:14:42.649] rknn_init, load model failed! [ERROR] fastdeploy/runtime/backends/rknpu2/rknpu2_backend.cc(157)::LoadModel rknn_init fail! ret=-6 [ERROR] fastdeploy/runtime/backends/rknpu2/rknpu2_backend.cc(100)::Init load model failed [ERROR] fastdeploy/runtime/runtime.cc(328)::CreateRKNPU2Backend Failed to initialize RKNPU2 backend. Aborted

另外通过netron查看转换后的rknn模型,无法可视化,会提示Unsupported container version ‘4’

image

MrMzl commented 1 year ago

模型选取错误,已解决