-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the issue
I am trying to build a small footprint Onnx runtime cross compiled with toolchain arm-linux-gnueabihf-9.1.0-gcc/g++ just using required ops. Using my model.onnx I generated required_operators.config which has these ops -
ai.onnx;17;Flatten,Gemm,LayerNormalization,Relu,Sigmoid
Including this file, I started a minimul build with the attached build script. But the build failed due to the following error -
-- Build files have been written to: /path/to/onnxruntime-v1.20.1/build-arm/MinSizeRel
2025-04-02 21:31:09,473 build [INFO] - Building targets for MinSizeRel configuration
2025-04-02 21:31:09,473 build [INFO] - /usr/local/bin/cmake --build build-arm/MinSizeRel --config MinSizeRel -- -j8
[ 0%] Running cpp protocol buffer compiler (lite) on /path/to/onnxruntime-v1.20.1/build-arm/MinSizeRel/_deps/onnx-src/onnx/onnx-data.proto
[ 0%] Running cpp protocol buffer compiler (lite) on /path/to/onnxruntime-v1.20.1/build-arm/MinSizeRel/_deps/onnx-src/onnx/onnx-operators-ml.proto
[ 0%] Running cpp protocol buffer compiler (lite) on /path/to/onnxruntime-v1.20.1/build-arm/MinSizeRel/_deps/onnx-src/onnx/onnx-ml.proto
gmake[2]: /path/to/protoc-3.21.12: Permission denied
gmake[2]: *** [CMakeFiles/onnx_proto.dir/build.make:88: onnx/onnx-data.pb.h] Error 127
gmake[2]: *** Waiting for unfinished jobs....
I downloaded and used the protoc initially for cross-compiling full onnx runtime in the following way -
-
found the version of prtotobuf for linux86_64 from cmake/deps.txt
-
downloaded and extracted
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-linux-x86_64.zip -
updated the ONNX_CUSTOM_PROTOC_EXECUTABLE path with the extracted protoc
This worked fine in case of earlier complete cross-compilation. But it failed with --minimal_build extended
Even without --include_ops_by_config /path/to/equired_operators.config, I get the permission denied error
Tried providing permission with chmod +x , but did not work
Please help me resolve this issue. I can attach the full build log if required.
Urgency
I am tasked to deploy an onnx model in a very resource-constrained arm environment. Using a memory card, I tested the model with full onnx runtime libs and it executed as expected. But the libs all total required ~50 mb which is not available during deployment. But I am sure a lightweight runtime can be built for the reduced ops mentioned above.
Target platform
ARM
Build script
cd onnxruntime-v1.20.1
./build.sh
--config MinSizeRel
--arm
--parallel
--build_dir build-arm
--cmake_extra_defines CMAKE_TOOLCHAIN_FILE=/path/to/arm-linux-custom.cmake
--cmake_extra_defines ONNX_CUSTOM_PROTOC_EXECUTABLE=/path/to/protoc-3.21.12
--cmake_extra_defines onnxruntime_CROSS_COMPILING=ON
--skip_tests
--build_shared_lib
--minimal_build extended
--include_ops_by_config /path/to/required_operators.config \
Error / output
gmake[2]: /path/to/protoc-3.21.12: Permission denied
gmake[2]: *** [CMakeFiles/onnx_proto.dir/build.make:88: onnx/onnx-data.pb.h] Error 127
gmake[2]: *** Waiting for unfinished jobs....
Visual Studio Version
No response
GCC / Compiler Version
arm-linux-gnueabihf-9.1.0-gcc/g++