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

Cross-compile mediapipe for ARM64 on SemiDrive X9U platform #5625

Open
Sirhxs opened this issue Sep 14, 2024 · 3 comments
Open

Cross-compile mediapipe for ARM64 on SemiDrive X9U platform #5625

Sirhxs opened this issue Sep 14, 2024 · 3 comments
Assignees
Labels
platform:embedded-linux-arm Issues related to Raspberry Pi, Coral Dev Board, Nvidia Jetson Nano, etc. type:build/install For Build and Installation issues type:support General questions

Comments

@Sirhxs
Copy link

Sirhxs commented Sep 14, 2024

OS Platform and Distribution

Ubuntu22.04

Compiler version

gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc

Programming Language and version

C++17、Python 3.10.12

Installed using virtualenv? pip? Conda?(if python)

No response

MediaPipe version

v0.10.15

Bazel version

6.1.1

XCode and Tulsi versions (if iOS)

No response

Android SDK and NDK versions (if android)

No response

Android AAR (if android)

None

OpenCV version (if running on desktop)

4.7.0

Describe the problem

Hi,I try to Cross-compile mediapipe as a C++ library on Ubuntu22.04,and I got this problem:bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc: 1: ELF�@k@�4D@8: not found bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc: 9: Syntax error: "(" unexpected

Complete Logs

My build command is:
bazel build -c opt --crosstool_top=@crosstool//:toolchains --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=aarch64 --compiler=gcc --cxxopt=-std=c++17 \
--action_env=PYTHON_BIN_PATH="/usr/bin/python3" \
--host_javabase=@local_jdk//:jdk \
--copt=-fPIC \
--linkopt=-static-libgcc \
--linkopt=-static-libstdc++ \
--cxxopt="-D__STDC_CONSTANT_MACROS" \
--cxxopt="-D__STDC_FORMAT_MACROS" \
--cxxopt="-D__STDC_LIMIT_MACROS" \
--action_env CC_TOOLCHAIN_NAME=aarch64-linux-gnu \
--action_env GCC_HOST_COMPILER_PATH=/tool/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc \
--action_env GCC_HOST_COMPILER_PREFIX=aarch64-linux-gnu- \
--action_env CC=aarch64-linux-gnu-gcc \
--action_env CXX=aarch64-linux-gnu-g++ \
--action_env AR=aarch64-linux-gnu-ar \
--action_env STRIP=aarch64-linux-gnu-strip \
--sandbox_debug --verbose_failures \
//mediapipe/examples/desktop:libmediapipe_arm64.so

err log:
part 1:
ERROR: /home/hesir/work/open-source/mediapipe/mediapipe/framework/BUILD:111:24: ProtoCompile mediapipe/framework/mediapipe_options.pb.h failed: (Exit 2): linux-sandbox failed: error executing command 
  (cd /home/hesir/.cache/bazel/_bazel_hesir/d487168c49c78571add856c1a0ec6785/sandbox/linux-sandbox/1319/execroot/mediapipe && \
  exec env - \
    AR=aarch64-linux-gnu-ar \
    CC=aarch64-linux-gnu-gcc \
    CC_TOOLCHAIN_NAME=aarch64-linux-gnu \
    CXX=aarch64-linux-gnu-g++ \
    GCC_HOST_COMPILER_PATH=/tool/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc \
    GCC_HOST_COMPILER_PREFIX=aarch64-linux-gnu- \
    PATH=/home/hesir/.cache/bazelisk/downloads/sha256/651a20d85531325df406b38f38a1c2578c49d5e61128fba034f5b6abdb3d303f/bin:/usr/local/bin:/home/hesir/work/open-source/tools/protoc-27.3-linux-aarch_64/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/home/hesir/.sdkman/candidates/java/current/bin:/home/hesir/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/tool/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin \
    PYTHON_BIN_PATH=/usr/bin/python3 \
    STRIP=aarch64-linux-gnu-strip \
    TMPDIR=/tmp \
  /home/hesir/.cache/bazel/_bazel_hesir/install/e63ada1a9406bff70c6efc9d97c3aeba/linux-sandbox -t 15 -w /home/hesir/.cache/bazel/_bazel_hesir/d487168c49c78571add856c1a0ec6785/sandbox/linux-sandbox/1319/execroot/mediapipe -w /tmp -w /dev/shm -S /home/hesir/.cache/bazel/_bazel_hesir/d487168c49c78571add856c1a0ec6785/sandbox/linux-sandbox/1319/stats.out -D -- bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc '--cpp_out=bazel-out/aarch64-opt/bin' -I. mediapipe/framework/mediapipe_options.proto)

part 2:
ERROR: /home/hesir/work/open-source/mediapipe/mediapipe/framework/formats/object_detection/BUILD:24:24: Generating Descriptor Set proto_library //mediapipe/framework/formats/object_detection:anchor_proto failed: (Exit 2): linux-sandbox failed: error executing command 
  (cd /home/hesir/.cache/bazel/_bazel_hesir/d487168c49c78571add856c1a0ec6785/sandbox/linux-sandbox/1320/execroot/mediapipe && \
  exec env - \
    AR=aarch64-linux-gnu-ar \
    CC=aarch64-linux-gnu-gcc \
    CC_TOOLCHAIN_NAME=aarch64-linux-gnu \
    CXX=aarch64-linux-gnu-g++ \
    GCC_HOST_COMPILER_PATH=/tool/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc \
    GCC_HOST_COMPILER_PREFIX=aarch64-linux-gnu- \
    PATH=/home/hesir/.cache/bazelisk/downloads/sha256/651a20d85531325df406b38f38a1c2578c49d5e61128fba034f5b6abdb3d303f/bin:/usr/local/bin:/home/hesir/work/open-source/tools/protoc-27.3-linux-aarch_64/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools:/home/hesir/.sdkman/candidates/java/current/bin:/home/hesir/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/tool/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin \
    PYTHON_BIN_PATH=/usr/bin/python3 \
    STRIP=aarch64-linux-gnu-strip \
    TMPDIR=/tmp \
  /home/hesir/.cache/bazel/_bazel_hesir/install/e63ada1a9406bff70c6efc9d97c3aeba/linux-sandbox -t 15 -w /home/hesir/.cache/bazel/_bazel_hesir/d487168c49c78571add856c1a0ec6785/sandbox/linux-sandbox/1320/execroot/mediapipe -w /tmp -w /dev/shm -S /home/hesir/.cache/bazel/_bazel_hesir/d487168c49c78571add856c1a0ec6785/sandbox/linux-sandbox/1320/stats.out -D -- bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc --direct_dependencies mediapipe/framework/formats/object_detection/anchor.proto '--direct_dependencies_violation_msg=%s is imported, but //mediapipe/framework/formats/object_detection:anchor_proto doesn'\''t directly depend on a proto_library that '\''srcs'\'' it.' '--descriptor_set_out=bazel-out/aarch64-opt/bin/mediapipe/framework/formats/object_detection/anchor_proto-descriptor-set.proto.bin' '-Imediapipe/framework/formats/object_detection/anchor.proto=mediapipe/framework/formats/object_detection/anchor.proto' mediapipe/framework/formats/object_detection/anchor.proto)

part 3:
bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc: 1: ELF�@k@�4D@8: not found
bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc: 9: Syntax error: "(" unexpected
1726284744.555571284: src/main/tools/linux-sandbox-pid1.cc:538: wait returned pid=2, status=0x200
1726284744.555598793: src/main/tools/linux-sandbox-pid1.cc:556: child exited normally with code 2
1726284744.559023275: src/main/tools/linux-sandbox.cc:233: child exited normally with code 2
Target //mediapipe/examples/desktop:libmediapipe_arm64.so failed to build
INFO: Elapsed time: 445.660s, Critical Path: 130.52s
INFO: 1794 processes: 483 internal, 1311 linux-sandbox.
FAILED: Build did NOT complete successfully
hesir@ubuntu2204:~/work/open-source/mediapipe$ file bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc
bazel-out/k8-opt-exec-50AE0418/bin/external/com_google_protobuf/protoc: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=5ab8da6c961216e9101c85fb0921d6d880c8929f, not stripped
@Sirhxs Sirhxs added the type:build/install For Build and Installation issues label Sep 14, 2024
@Sirhxs
Copy link
Author

Sirhxs commented Sep 14, 2024

the only script I modify is: mediapipe/examples/desktop/BUILD
I don't understand the syntax rules of Bazel, nor do I know how to configure it. The configuration I refer to is as follows:
4

@ayushgdev ayushgdev added type:support General questions platform:c++ Issues specific to C++ framework in mediapipe platform:embedded-linux-arm Issues related to Raspberry Pi, Coral Dev Board, Nvidia Jetson Nano, etc. and removed platform:c++ Issues specific to C++ framework in mediapipe labels Sep 20, 2024
@ayushgdev
Copy link
Collaborator

@Sirhxs Would you please provide the exact steps to reproduce the issue?

@ayushgdev ayushgdev added the stat:awaiting response Waiting for user response label Sep 20, 2024
@Sirhxs
Copy link
Author

Sirhxs commented Sep 23, 2024

@Sirhxs 您能提供重现该问题的具体步骤吗?

  1. Clone the mediapipe github repository.
  2. Modify mediapipe/examples/desktop/BUILD.
  3. Execute the compilation command.
    The above are all my compilation steps. Then, I modified WORKSPACE and third_party/opencv_linux.BUILD, but got the same compilation error. Is there something wrong with my compilation command or is there something wrong with the mediapipe/examples/desktop/BUILD configuration file that generates the target library? If so, how should I configure the cross-compilation tool to generate a mediapipe library in C++ or python format? Can you give a BUILD configuration example and cross-compilation command. That's all. Thank you very much!
    1
    2
    3

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:embedded-linux-arm Issues related to Raspberry Pi, Coral Dev Board, Nvidia Jetson Nano, etc. type:build/install For Build and Installation issues type:support General questions
Projects
None yet
Development

No branches or pull requests

2 participants