c++ - 如何在 M1 mac 上使用 C++ 运行 mediapipe

标签 c++ apple-m1 mediapipe

环境
Macbook air M1 2020。
大苏尔 11.3.1。
我想做什么
我想成功运行下面的“mediapipe c++ hello_world”。
https://google.github.io/mediapipe/getting_started/install.html#installing-on-macos
我尝试了以下尝试但失败了。
尝试1

只需遵循指南
https://google.github.io/mediapipe/getting_started/install.html#installing-on-macos

  • 4.安装OpenCV和FFmpeg。 => 我使用了选项 1。

  • 漏洞
    在第 6 课中,我遇到了下面的错误。
    // run lesson 6
    mediapipe % bazel run --define MEDIAPIPE_DISABLE_GPU=1 \
        mediapipe/examples/desktop/hello_world:hello_world
    2021/05/23 21:06:14 Downloading https://releases.bazel.build/3.7.2/release/bazel-3.7.2-darwin-arm64...
    2021/05/23 21:06:16 could not download Bazel: HTTP GET https://releases.bazel.build/3.7.2/release/bazel-3.7.2-darwin-arm64 failed with error 404
    mediapipe %
    
    尝试2
    “try1 bug”表示bazel试图下载 bazel-3.7.2-darwin-arm64 来自 github 发布。
    但是,发布版本 3.7.2 没有 darwin-arm64 的类型 .
    https://github.com/bazelbuild/bazel/releases/tag/3.7.2
    幸运的是,发布版本 4.1.0 具有 darwin-arm64 的类型。
    https://github.com/bazelbuild/bazel/releases/tag/4.1.0
    然后我尝试下载 bazel-4.1.0-darwin-arm64 .

    在根存储库“mediapipe”中,修复“.bazelversion”文件如下。
    4.1.0
    
    然后,重试第 6 课并开始下载。
    漏洞
    但是下载没有成功完成:我遇到了另一个错误,如下所示。
    // run lesson 6 again
    mediapipe % bazel run --define MEDIAPIPE_DISABLE_GPU=1 \
        mediapipe/examples/desktop/hello_world:hello_world
    
    ~~download process~~
    
    ERROR: /Users/<some_mid_path>/mediapipe/mediapipe/framework/BUILD:971:11: Compiling mediapipe/framework/scheduler_queue.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 60 argument(s) skipped)
    
    Use --sandbox_debug to see verbose messages from the sandbox
    mediapipe/framework/scheduler_queue.cc:212:3: error: expected expression
      AUTORELEASEPOOL {
      ^
    mediapipe/framework/scheduler_queue.cc:29:25: note: expanded from macro 'AUTORELEASEPOOL'
    #define AUTORELEASEPOOL @autoreleasepool
                            ^
    mediapipe/framework/scheduler_queue.cc:226:5: error: use of undeclared identifier 'is_idle'
        is_idle = IsIdle();
        ^
    mediapipe/framework/scheduler_queue.cc:228:7: error: use of undeclared identifier 'is_idle'
      if (is_idle && idle_callback_) {
          ^
    3 errors generated.
    Error in child process '/usr/bin/xcrun'. 1
    Target //mediapipe/examples/desktop/hello_world:hello_world failed to build
    Use --verbose_failures to see the command lines of failed build steps.
    INFO: Elapsed time: 1.430s, Critical Path: 1.26s
    INFO: 4 processes: 3 internal, 1 darwin-sandbox.
    FAILED: Build did NOT complete successfully
    FAILED: Build did NOT complete successfully
    
    mediapipe % 
    
    
    现在情况
    那我暂时放弃了,向你提问!
    有人能解决这个问题吗??
    提前致谢。

    最佳答案

    我成功地构建了 HelloWorld.cc。
    我还设法在 M1 MAC 上编译了 Android。 NDK 版本和权限存在一些问题,但最终它在我的 S8 Plus 上编译并运行。
    我的设置

  • MacBook Pro(13 英寸,M1,2020)
  • macOS Big Sur 11.5.1
  • 使用的 ndk 版本:r20b(手动下载并编辑到 ndk 的 WORKSPACE 路径)

  • 在第一次编译期间,您会遇到很多权限错误问题,请转到并在构建期间保持打开 > 系统偏好设置 > 安全和隐私 > 常规。
    当弹出错误时,允许继续并重新启动构建。在构建之前将需要大约 8-10 个权限。
    下面是构建过程的最后一点。
    Warning: skipping import of repository 
    'build_bazel_apple_support' because it already exists.
    
    DEBUG: /private/var/tmp/_bazel_jeranio/794c1b4078a0aeb97ae7a379447a99a6/external/org_tensorflow/third_party/repo.bzl:108:14: 
    Warning: skipping import of repository 'bazel_skylib' because it already exists.
    
    DEBUG: /private/var/tmp/_bazel_jeranio/794c1b4078a0aeb97ae7a379447a99a6/external/org_tensorflow/third_party/repo.bzl:108:14: 
    Warning: skipping import of repository 'pybind11' because it already exists.
    
    DEBUG: /private/var/tmp/_bazel_jeranio/794c1b4078a0aeb97ae7a379447a99a6/external/tf_runtime/third_party/cuda/dependencies.bzl:51:10: The following command will download NVIDIA proprietary software. By using the software you agree to comply with the terms of the license agreement that accompanies the software. If you do not agree to the terms of the license agreement, do not use the software.
    
    INFO: Analyzed target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu (0 packages loaded, 0 targets configured).
    INFO: Found 1 target...
    
    Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu up-to-date:
      bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu_deploy.jar
      bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu_unsigned.apk
      bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu.apk
    INFO: Elapsed time: 2.984s, Critical Path: 0.97s
    INFO: 1 process: 1 internal.
    INFO: Build completed successfully, 1 total action
    
    jeranio at Jerrys-MacBook-Pro in ~/mediapipe on master [!?]
    

    关于c++ - 如何在 M1 mac 上使用 C++ 运行 mediapipe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67660034/

    相关文章:

    c++ - 在 VC 2015 上使用带有字符串的宏失败

    c++ - Direct2D C++ 用户输入

    c++ - 嵌套C++模板定义

    python - 找不到满足 mediapipe 要求的版本(来自版本 : none)

    c++ - 切换到 VS12 v110_xp 时缺少 Winusb.h

    python - 如何在 Apple M1 芯片的 Mac 上使用 Tensorflow 检查 GPU 可访问性?

    Firebase 在 M1 Mac 上损坏

    macos - Quasar Electron版本无法在具有arm64架构的M1 Mac mini上运行

    python - 安装 mediapipe 库后 cv2 不工作

    python - 如何获取手部图像中点的坐标?