目标板子是armhf架构,onnxruntime1.12.0版本编译不出onnxruntime_cxx_api.h等文件,需要依赖armhf对应的libonnxruntime.so
请教一下,我想在RV1109机子上部署FastDeploy(双核armv7,均属于armhf),看到目前只支持arm64和x86的。 用交叉编译的方式可以编译到100%,但是最后会链接相关so,而下载来了so都是x86的。
目前测试环境是x86的虚拟机ubuntu18,因为编译速度较快。
我已经在板子上编译出paddle2onnx.so了,但是用microsoft/onnxruntime仓库编译不出这些文件: third_libs/install/onnxruntime$ tree . ├── include │ ├── cpu_provider_factory.h │ ├── onnxruntime_c_api.h │ ├── onnxruntime_cxx_api.h │ ├── onnxruntime_cxx_inline.h │ ├── onnxruntime_run_options_config_keys.h │ ├── onnxruntime_session_options_config_keys.h │ └── provider_options.h └── lib ├── libonnxruntime.so -> libonnxruntime.so.1.12.0 └── libonnxruntime.so.1.12.0
2 directories, 9 files
获得的是这些: ~/work/fastdeploy/onnxruntime/install$ tree . ├── bin │ └── onnx_test_runner ├── include │ └── onnxruntime │ └── core │ ├── common │ │ ├── basic_types.h │ │ ├── code_location.h │ │ ├── common.h │ │ ├── const_pointer_container.h │ │ ├── denormal.h │ │ ├── eigen_common_wrapper.h │ │ ├── exceptions.h │ │ ├── gsl_suppress.h │ │ ├── inlined_containers_fwd.h │ │ ├── inlined_containers.h │ │ ├── logging │ │ │ ├── capture.h │ │ │ ├── isink.h │ │ │ ├── logging.h │ │ │ ├── macros.h │ │ │ └── severity.h │ │ ├── make_string.h │ │ ├── optional.h │ │ ├── parse_string.h │ │ ├── profiler_common.h │ │ ├── span_utils.h │ │ ├── spin_pause.h │ │ ├── status.h │ │ └── string_helper.h │ ├── framework │ │ ├── allocator.h │ │ ├── alloc_kind.h │ │ ├── buffer_deleter.h │ │ ├── customregistry.h │ │ ├── data_types.h │ │ ├── data_types_internal.h │ │ ├── endian.h │ │ ├── execution_provider.h │ │ ├── fence.h │ │ ├── float16.h │ │ ├── framework_common.h │ │ ├── func_api.h │ │ ├── kernel_def_builder.h │ │ ├── kernel_registry.h │ │ ├── op_kernel_context.h │ │ ├── op_kernel.h │ │ ├── op_kernel_info.h │ │ ├── op_node_proto_helper.h │ │ ├── ortdevice.h │ │ ├── ortmemoryinfo.h │ │ ├── ort_value.h │ │ ├── provider_options.h │ │ ├── provider_options_utils.h │ │ ├── provider_shutdown.h │ │ ├── run_options.h │ │ ├── sparse_tensor.h │ │ ├── tensor.h │ │ ├── tensor_shape.h │ │ └── to_tensor_proto_element_type.h │ ├── graph │ │ ├── basic_types.h │ │ ├── constants.h │ │ ├── function.h │ │ ├── graph.h │ │ ├── graph_nodes.h │ │ ├── graph_viewer.h │ │ ├── indexed_sub_graph.h │ │ ├── node_arg.h │ │ └── schema_registry.h │ ├── optimizer │ │ ├── graph_transformer_config.h │ │ ├── graph_transformer.h │ │ ├── graph_transformer_level.h │ │ ├── graph_transformer_utils.h │ │ ├── rewrite_rule.h │ │ └── rule_based_graph_transformer.h │ ├── providers │ │ └── cpu │ │ └── cpu_provider_factory.h │ └── session │ ├── environment.h │ ├── experimental_onnxruntime_cxx_api.h │ ├── experimental_onnxruntime_cxx_inline.h │ ├── onnxruntime_c_api.h │ ├── onnxruntime_cxx_api.h │ ├── onnxruntime_cxx_inline.h │ ├── onnxruntime_run_options_config_keys.h │ ├── onnxruntime_session_options_config_keys.h │ └── snippets.dox └── lib ├── libonnxruntime_common.a ├── libonnxruntime_flatbuffers.a ├── libonnxruntime_framework.a ├── libonnxruntime_graph.a ├── libonnxruntime_mlas.a ├── libonnxruntime_optimizer.a ├── libonnxruntime_providers.a ├── libonnxruntime_providers_shared.so ├── libonnxruntime_session.a ├── libonnxruntime_util.a └── pkgconfig └── libonnxruntime.pc
14 directories, 89 files
我已经根据FastDeploy 0.3.0用onnxruntime 1.12.0,把onnxruntime的仓库切换到rel-1.12.0版本了。 请教一下,onnxruntime相关库和文件的具体编译方法是什么?谢谢。 仔细查看目录,原来后者已经生成了所需的头文件,还差so,不知道我可否通过改名,再编译?
你onnxruntime的编译命令具体是啥?另外,这是想将fastdeploy移植到armv7架构上?
还有编译fastdeploy的具体命令
@xxJian 你是要用rv1109的arm cpu,不考虑使用上面的NPU吗?
@DefTruth 是的,想要移植到armv7板子上部署。现在好多人脸闸机都是这架构。官方给的sdk能编译出demo,但接口复杂。 目前先在x86上编译,尝试自己编译出FastDeploy依赖的第三方库。 这是编译FastDeploy的命令:
git clone https://github.com/PaddlePaddle/FastDeploy.git cd FastDeploy git checkout develop mkdir build && cd build cmake .. -DENABLE_ORT_BACKEND=ON
-DENABLE_VISION=ON
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-dev make -j8 make install
这是编译onnxruntime的指令:
- 获取源码 git clone https://github.com/microsoft/onnxruntime
- Update submodules git submodule update --init --recursive
- 安装Protobuf git clone https://github.com/protocolbuffers/protobuf.git cd protobuf git checkout v3.18.x mkdir build_source && cd build_source cmake ../cmake -DCMAKE_INSTALL_PREFIX=${PWD}/installed_protobuf_lib -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release make -j8 make install // 将编译目录加入环境变量 export PATH=/home/xxjianvm/work/fastdeploy/Paddle2ONNX/third/protobuf/build_x64/installed_protobuf_lib/bin:$PATH
- onnxruntime git checkout rel-1.12.0 # 这个版本对应着FastDeploy- 0.3版本 mkdir build && cd build cmake ../cmake
-DONNX_CUSTOM_PROTOC_EXECUTABLE=/home/xxjianvm/work/fastdeploy/Paddle2ONNX/third/protobuf/build_x64/installed_protobuf_lib/bin/protoc
-DCMAKE_BUILD_TYPE=Release
-Dprotobuf_WITH_ZLIB=OFF
-Donnxruntime_ENABLE_PYTHON=OFF
-Donnxruntime_DEV_MODE=OFF
-DCMAKE_INSTALL_PREFIX=/home/xxjianvm/work/fastdeploy/onnxruntime/install -Donnxruntime_GCC_STATIC_CPP_RUNTIME=ON
-Donnxruntime_BUILD_SHARED_LIB=OFF
make -j8
- 测试编译出来的库Fastdeploy认不认 git clone https://github.com/PaddlePaddle/FastDeploy.git cd FastDeploy git checkout develop mkdir build && cd build cmake .. -DENABLE_ORT_BACKEND=ON
-DENABLE_VISION=ON
-DCMAKE_INSTALL_PREFIX=${PWD}/fastdeploy-dev make -j8 发现third_libs/install/onnxruntime/lib中的 libonnxruntime.so rm -rf third_libs/install/onnxruntime cp -r /home/xxjianvm/work/fastdeploy/onnxruntime/install third_libs/install/onnxruntime cd third_libs/install/onnxruntime/lib ln third_libs/install/onnxruntime/lib/libonnxruntime_providers_shared.so third_libs/install/onnxruntime/lib/libonnxruntime.so
错误: /home/xxjianvm/work/fastdeploy/FastDeploy/./fastdeploy/backends/ort/ort_backend.h:23:10: fatal error: onnxruntime_cxx_api.h: No such file or directory #include "onnxruntime_cxx_api.h" // NOLINT
手上的armhf板子是2GB内存的,同架构基本最大就2GB内存了。上次用arm64的板子编译paddlepaddle要16GB才够用。故选择onnxruntime作为backend。
@leiqing1 考虑过,自带的NPU不好用。rknn-toolkit最新版本的第三方库onnx版本记得只到1.8,好多算子不支持,开发比cpu难度更大。我自己也不熟人脸识别算法,FastDeploy的facedetect和faceid算法都不错。
此ISSUE由于一年未更新,将会关闭处理,如有需要,可再次更新打开。