Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Onnx runtime cross compilation with toolchain arm-linux-gnueabihf-9.1.0-gcc/g++ with reduced ops config failing #24279

Closed
work-dnd opened this issue Apr 2, 2025 · 2 comments · May be fixed by #24012
Assignees
Labels
build build issues; typically submitted using template

Comments

@work-dnd
Copy link

work-dnd commented Apr 2, 2025

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 -

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++

@work-dnd work-dnd added the build build issues; typically submitted using template label Apr 2, 2025
@snnn
Copy link
Member

snnn commented Apr 4, 2025

I am working on a fix.

@work-dnd
Copy link
Author

Solved!

"--cmake_extra_defines ONNX_CUSTOM_PROTOC_EXECUTABLE=/path/to/protoc-3.21.12" - This line should be
--cmake_extra_defines ONNX_CUSTOM_PROTOC_EXECUTABLE=/path/to/protoc-3.21.12/bin/protoc (path upto protoc executable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants