Open Newer2019 opened 3 years ago
The CMake
build system is trying to run the aarch64 executable binary of the protoc compiler to generate code. It's not working because of course your build host is x86_64. I'm having the same problem.
This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.
I cross-built onnxruntime from Linux x86_64 to Linux aarch64 by telling CMake to run the native x86_64 protoc
like this:
let
# https://onnxruntime.ai/docs/build/inferencing.html#cross-compiling-on-linux
# > 4 Generate CMake toolchain file Save the following content as tool.cmake
toolcmakeCross = writeText "tool.cmake" ''
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER aarch64-unknown-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER aarch64-unknown-linux-gnu-g++)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
'';
cmakeFlags = []
] ++ lib.optional (stdenv.buildPlatform.isx86_64 && stdenv.hostPlatform.isAarch64) [
# https://onnxruntime.ai/docs/build/inferencing.html#cross-compiling-on-linux
# > 2 Get a pre-compiled protoc:
# > The version must match the one onnxruntime is using. Currently we are using 3.11.2.
# Current version is actually 3.16, see
# https://github.com/microsoft/onnxruntime/tree/v1.10.0/cmake/external
"-DONNX_CUSTOM_PROTOC_EXECUTABLE=${pkgsBuildBuild.protobuf3_16}/bin/protoc"
"-DCMAKE_TOOLCHAIN_FILE=${toolcmakeCross}"
]
cross compile on centos 7 for arm linux
using aarch64-linux-gnu-gcc and aarch64-linux-gnu-g++
armnn and ACL compile success when compile onnxruntime, error occurs as follows:
[ 9%] Built target re2 [ 12%] Built target flatc [ 14%] Built target onnxruntime_mlas [ 22%] Built target libprotobuf Consolidate compiler generated dependencies of target libprotoc [ 30%] Built target libprotoc Consolidate compiler generated dependencies of target protoc [ 30%] Built target protoc [ 30%] Running C++ protocol buffer compiler on /data2/jin/compiles/onnxruntime/buildx/external/onnx/onnx/onnx-ml.proto /bin/sh: ../protobuf/cmake/protoc-3.16.0.0: cannot execute binary file make[2]: [external/onnx/onnx/onnx-ml.pb.cc] Error 126 make[1]: [external/onnx/CMakeFiles/gen_onnx_proto.dir/all] Error 2 make: *** [all] Error 2
please help and many thanks...