mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

cross compilation mediapipe for raspberryPi error

Open reolf opened this issue 3 years ago • 4 comments
trafficstars

System information

  • OS Platform and Distribution : Linux Ubuntu 18.04(host) , Debian buster(docker image)
  • Compiler version : g++8
  • MediaPipe version: 0.8.10.2
  • Bazel version: 5.2.0

Describe the problem: I want to build the hand_tracking demo for RaspberryPi through docker. so I follow the instruction (https://github.com/google/mediapipe/tree/master/mediapipe/examples/coral#cross-compilation) to build the demo.

the step like this:

  1. clone the mediapipe source and go into the directory
git clone https://github.com/google/mediapipe.git
cd mediapipe
  1. build the docker image
make -C mediapipe/examples/coral PLATFORM=armhf docker

after image build, it will auto go into the docker container.

  1. modify the Makefile(path: /mediapipe/mediapipe/example/coral/)
  • remove the '--define MEDIAPIPE_EDGE_TPU=all',because I do not need the Edge TPU
  • add the --copt="-std=gnu99", because it will occur the error
ERROR: /home/pi/.cache/bazel/_bazel_pi/4884d566396e9b67b62185751879ad14/external/XNNPACK/BUILD.bazel:9251:19: Compiling src/jit/memory.c failed: (Exit 1): arm-linux-gnueabihf-gcc failed: error executing command /usr/bin/arm-linux-gnueabihf-gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-march=armv7-a' '-mfpu=neon-vfpv4' -g0 -O3 ... (remaining 76 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/XNNPACK/src/jit/memory.c: In function 'xnn_allocate_code_memory':
external/XNNPACK/src/jit/memory.c:35:68: error: 'MAP_ANONYMOUS' undeclared (first use in this function)
   void* p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  1. build the hand_tracking demo.
make -C mediapipe/examples/coral \
BAZEL_TARGET=mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu \
build

in the compilation process, the error like this: Complete Logs:

ERROR: /root/.cache/bazel/_bazel_root/4884d566396e9b67b62185751879ad14/external/XNNPACK/BUILD.bazel:7689:19: Compiling src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c failed: (Exit 1): arm-linux-gnueabihf-gcc failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/4884d566396e9b67b62185751879ad14/sandbox/processwrapper-sandbox/1548/execroot/mediapipe && \
  exec env - \
    PATH=/root/.cache/bazelisk/downloads/bazelbuild/bazel-5.2.0-linux-x86_64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
  /usr/bin/arm-linux-gnueabihf-gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-march=armv7-a' '-mfpu=neon-vfpv4' -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections -funsafe-math-optimizations -ftree-vectorize '-std=c99' -MD -MF bazel-out/armv7a-opt/bin/external/XNNPACK/_objs/neonfp16_prod_microkernels/0/vcvt-neonfp16-x16.d '-frandom-seed=bazel-out/armv7a-opt/bin/external/XNNPACK/_objs/neonfp16_prod_microkernels/0/vcvt-neonfp16-x16.o' -DPTHREADPOOL_NO_DEPRECATED_API -iquote external/XNNPACK -iquote bazel-out/armv7a-opt/bin/external/XNNPACK -iquote external/FP16 -iquote bazel-out/armv7a-opt/bin/external/FP16 -iquote external/pthreadpool -iquote bazel-out/armv7a-opt/bin/external/pthreadpool -iquote external/FXdiv -iquote bazel-out/armv7a-opt/bin/external/FXdiv -iquote external/cpuinfo -iquote bazel-out/armv7a-opt/bin/external/cpuinfo -iquote external/clog -iquote bazel-out/armv7a-opt/bin/external/clog -Ibazel-out/armv7a-opt/bin/external/FP16/_virtual_includes/FP16 -Ibazel-out/armv7a-opt/bin/external/pthreadpool/_virtual_includes/pthreadpool -Ibazel-out/armv7a-opt/bin/external/FXdiv/_virtual_includes/FXdiv -Ibazel-out/armv7a-opt/bin/external/cpuinfo/_virtual_includes/cpuinfo -Ibazel-out/armv7a-opt/bin/external/clog/_virtual_includes/clog -isystem external/XNNPACK/include -isystem bazel-out/armv7a-opt/bin/external/XNNPACK/include -isystem external/XNNPACK/src -isystem bazel-out/armv7a-opt/bin/external/XNNPACK/src -isystem external/FP16/include -isystem bazel-out/armv7a-opt/bin/external/FP16/include -isystem external/pthreadpool/include -isystem bazel-out/armv7a-opt/bin/external/pthreadpool/include -isystem external/FXdiv/include -isystem bazel-out/armv7a-opt/bin/external/FXdiv/include -w '-std=gnu99' -Iinclude -Isrc -marm '-march=armv7-a' '-mfpu=neon-fp16' '-std=c99' -O2 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c -o bazel-out/armv7a-opt/bin/external/XNNPACK/_objs/neonfp16_prod_microkernels/0/vcvt-neonfp16-x16.o)
# Configuration: 4a25d7d1036a202756e98f501cc12c61beb0baeb60352ed38a1f8a029bb360c2
# Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c: In function 'xnn_f16_f32_vcvt_ukernel__neonfp16_x16':
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:31:11: error: unknown type name 'float16x8_t'
     const float16x8_t vh0 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
           ^~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:32:11: error: unknown type name 'float16x8_t'
     const float16x8_t vh1 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
           ^~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:34:29: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     const float32x4_t vf0 = vcvt_f32_f16(vget_low_f16(vh0));
                             ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:35:29: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     const float32x4_t vf1 = vcvt_f32_f16(vget_high_f16(vh0));
                             ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:36:29: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     const float32x4_t vf2 = vcvt_f32_f16(vget_low_f16(vh1));
                             ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:37:29: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     const float32x4_t vf3 = vcvt_f32_f16(vget_high_f16(vh1));
                             ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:45:11: error: unknown type name 'float16x8_t'
     const float16x8_t vh = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
           ^~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:47:31: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     const float32x4_t vf_lo = vcvt_f32_f16(vget_low_f16(vh));
                               ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:48:31: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     const float32x4_t vf_hi = vcvt_f32_f16(vget_high_f16(vh));
                               ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:56:11: error: unknown type name 'float16x8_t'
     const float16x8_t vh = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
           ^~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:58:22: error: incompatible types when initializing type 'float32x4_t' using type 'int'
     float32x4_t vf = vcvt_f32_f16(vget_low_f16(vh));
                      ^~~~~~~~~~~~
external/XNNPACK/src/f16-f32-vcvt/gen/vcvt-neonfp16-x16.c:61:10: error: incompatible types when assigning to type 'float32x4_t' from type 'int'
       vf = vcvt_f32_f16(vget_high_f16(vh));
          ^
Target //mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu failed to build
INFO: Elapsed time: 684.491s, Critical Path: 527.97s
INFO: 2222 processes: 677 internal, 1545 processwrapper-sandbox.
FAILED: Build did NOT complete successfully

reolf avatar Aug 03 '22 06:08 reolf

Hi @reolf, Have you looked at this similar closed issue #926 and comment. Thank you!

kuaashish avatar Aug 03 '22 08:08 kuaashish

hi @kuaashish , I had looked, but it seems not the same error.

reolf avatar Aug 03 '22 09:08 reolf

Hi @reolf, Could you confirm that you are able to build the Hello_world_example successfully as mentioned here. Thank you!

kuaashish avatar Aug 04 '22 06:08 kuaashish

hi @kuaashish, I had tried to build the hello_world example. it's no problem. and can run on raspberryPi.

reolf avatar Aug 04 '22 07:08 reolf

Hi @reolf, Currently only Face Detection and Object Detection models are available on the Edge devices. MediaPipe has limited resources for new features. We will let you know if there is any specific update on this request.

Please follow this issue #426 and #426(comment) for more information.

Thank you!

kuaashish avatar Aug 16 '22 09:08 kuaashish

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Aug 23 '22 10:08 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Aug 30 '22 11:08 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Aug 30 '22 11:08 google-ml-butler[bot]

I had the same issue as reolf I tried to build hand tracking in the mediapipe repo, but got the error in XNNPACK If any solution, pls let me know it

mauricewells avatar Sep 05 '22 17:09 mauricewells

Of course, I successfully built hand tracking for coral device(Mendel Linux=Arm 64bit), but I failed to build that for Raspberry Pi(Raspbian Arm 32 bit)

mauricewells avatar Sep 05 '22 17:09 mauricewells