Mediapipe in Mac M1 pro machine with ARM, facing issue with AUTORELEASEPOOL while bazel build for hello_world
I am using the latest Mac M1 pro (ARM) machine and was trying to install mediapipe as per this tutorial - https://google.github.io/mediapipe/getting_started/install.html#installing-on-macos.
I was consistently getting the following error during this command:
$ bazel run --define MEDIAPIPE_DISABLE_GPU=1 \
mediapipe/examples/desktop/hello_world:hello_world
Error:
mediapipe/framework/scheduler_queue.cc:212:3: error: expected expression
AUTORELEASEPOOL {
^
mediapipe/framework/scheduler_queue.cc:29:25: note: expanded from macro 'AUTORELEASEPOOL'
Solution 1:
While looking into the error carefully and tracing back to the mediapipe framework file scheduler_queue.cc I found there is some issue in AUTORELEASEPOOL define.
I've updated this line ''' #define AUTORELEASEPOOL @autoreleasepool ''' to ''' #define AUTORELEASEPOOL '''
and it works for me, as I'm able to build mediapipe hello_world as expected.
Seems like, scheduler_queue.cc has not been written carefully considering this type of issues or maybe needs to be tested more.
Hopefully, this will help you all.
Thanks
Solution 2:
It looks like M1 Mac is not detected properly by Bazel as an apple build and a change in mediapipe/framework/BUILD
needs to be done
cc_library(
name = "scheduler_queue",
srcs = ["scheduler_queue.cc"],
hdrs = [
"scheduler_queue.h",
"scheduler_shared.h",
],
copts = select({
- "//conditions:default": [],
+ "//conditions:default": ["-ObjC++"],
"//mediapipe:apple": [
"-ObjC++",
],
}),
This will allow Objective C++ directive @autoreleasepool
to be available which is used here for memory management. It is not a good idea to get rid of it in code (as in the answer from hemant kshirsagar).