google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.07k stars 5.11k forks source link

hand_landmark_model_loader_graph_text_to_binary_graph #4294

Closed lyqaiym closed 1 year ago

lyqaiym commented 1 year ago

OS Platform and Distribution

macOs 13.3.1 (22E261)

Compiler version

No response

Programming Language and version

java version "1.8.0_271"

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

No response

MediaPipe version

master

Bazel version

6.1.1

XCode and Tulsi versions (if iOS)

14.3

Android SDK and NDK versions (if android)

ndk-r21

Android AAR (if android)

No

OpenCV version (if running on desktop)

No response

Describe the problem

bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu

build ERROR

if add --define MEDIAPIPE_DISABLE_GPU=1

build SUCCESS

bug open app crash

#if MEDIAPIPE_DISABLE_GPU
  LOG(FATAL) << "GPU support has been disabled in this build!";
#else

Complete Logs

external/com_google_absl/absl/base/attributes.h:674:49: note: expanded from macro 'ABSL_DEPRECATED'
#define ABSL_DEPRECATED(message) __attribute__((deprecated(message)))
                                                ^
In file included from mediapipe/framework/tool/text_to_binary_graph.cc:27:
In file included from ./mediapipe/framework/port/ret_check.h:18:
In file included from ./mediapipe/framework/deps/ret_check.h:19:
./mediapipe/framework/deps/status_builder.h:87:12: warning: 'Status' is deprecated: Use absl::Status directly [-Wdeprecated-declarations]
  operator Status() &&;
           ^
./mediapipe/framework/deps/status.h:30:14: note: 'Status' has been explicitly marked deprecated here
using Status ABSL_DEPRECATED("Use absl::Status directly") = absl::Status;
             ^
external/com_google_absl/absl/base/attributes.h:674:49: note: expanded from macro 'ABSL_DEPRECATED'
#define ABSL_DEPRECATED(message) __attribute__((deprecated(message)))
                                                ^
2 warnings generated.
ERROR: /Users/linyuqiang/github/mediapipe/mediapipe/modules/hand_landmark/BUILD:35:26: Linking mediapipe/modules/hand_landmark/hand_landmark_model_loader_graph_text_to_binary_graph [for tool] failed: (Exit 1): cc_wrapper.sh failed: error executing command (from target //mediapipe/modules/hand_landmark:hand_landmark_model_loader_graph_text_to_binary_graph) external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-opt-exec-50AE0418/bin/mediapipe/modules/hand_landmark/hand_landmark_model_loader_graph_text_to_binary_graph-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
stderr (/private/var/tmp/_bazel_linyuqiang/cc896c897553f99ee8ee66f7814f29cf/execroot/mediapipe/bazel-out/_tmp/actions/stderr-5563) 1460423 exceeds maximum size of --experimental_ui_max_stdouterr_bytes=1048576 bytes; skipping
Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1782.904s, Critical Path: 460.32s
INFO: 3564 processes: 107 internal, 3438 darwin-sandbox, 19 worker.
FAILED: Build did NOT complete successfully
ayushgdev commented 1 year ago

Hi @lyqaiym The issue is because MP is not able to find OpenCV . Probably need to configure the paths correctly and it should work. Can you check the comments in a thread from https://github.com/google/mediapipe/issues/764#issuecomment-638984070 onwards?

Also, check the WORKSPACE file. In this file, the path to opencv should be correct. So you just check the path of the installed opencv packages (for example, libopencv-calib3d-dev) and modify the path here accordingly.

new_local_repository(
    name = "macos_opencv",
    build_file = "@//third_party:opencv_macos.BUILD",
    # For local MacOS builds, the path should point to an opencv@3 installation.
    # If you edit the path here, you will also need to update the corresponding
    # prefix in "opencv_macos.BUILD".
    path = "/opt/homebrew",
)
lyqaiym commented 1 year ago

It doesn't seem to have anything to do with OpenCV. I select Option 2. port install opencv3 I haven't changed the file. macos_opencv path = "/usr/local" opencv_macos.BUILD PREFIX = "opt/opencv@3"

cc_library( name = "opencv", srcs = glob( [ paths.join(PREFIX, "lib/libopencv_core.dylib"), paths.join(PREFIX, "lib/libopencv_calib3d.dylib"), paths.join(PREFIX, "lib/libopencv_features2d.dylib"), paths.join(PREFIX, "lib/libopencv_highgui.dylib"), paths.join(PREFIX, "lib/libopencv_imgcodecs.dylib"), paths.join(PREFIX, "lib/libopencv_imgproc.dylib"), paths.join(PREFIX, "lib/libopencv_video.dylib"), paths.join(PREFIX, "lib/libopencv_videoio.dylib"), ], ), hdrs = glob([paths.join(PREFIX, "include/opencv2/*/.h*")]), includes = [paths.join(PREFIX, "include/")], linkstatic = 1, visibility = ["//visibility:public"], )

lyqaiym commented 1 year ago

bazel build --verbose_failures --sandbox_debug

ERROR: /Users/username/github/mediapipe/mediapipe/modules/hand_landmark/BUILD:167:26: Linking mediapipe/modules/hand_landmark/hand_landmark_landmarks_to_roi_graph_text_to_binary_graph [for tool] failed: (Exit 1): sandbox-exec failed: error executing command (cd /private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/sandbox/darwin-sandbox/9300/execroot/mediapipe && \ exec env - \ APPLE_SDK_PLATFORM=MacOSX \ APPLE_SDK_VERSION_OVERRIDE=13.3 \ DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \ PATH=/opt/local/bin:/Users/username/bin:/Users/username/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/username/Library/Android/sdk/platform-tools:/Users/username/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/::/Users/username/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst/gradle-6.1.1/bin:/Users/username/Library/Android/sdk/platform-tools:/Users/username/Android/sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/darwin-x86_64/bin/::/Users/username/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst/gradle-6.1.1/bin \ SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk \ TMPDIR=/var/folders/1z/8xljm54j7h3fq1x3_bwkvyt40000gp/T/ \ XCODE_VERSION_OVERRIDE=14.3.0.14E222b \ ZERO_AR_DATE=1 \ /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/sandbox/darwin-sandbox/9300/sandbox.sb /var/tmp/_bazel_username/install/f822566ff435ccaad75bcfd3b2719b0b/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/sandbox/darwin-sandbox/9300/stats.out' external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-opt-exec-50AE0418/bin/mediapipe/modules/hand_landmark/hand_landmark_landmarks_to_roi_graph_text_to_binary_graph-2.params) stderr (/private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/execroot/mediapipe/bazel-out/_tmp/actions/stderr-299) 1460423 exceeds maximum size of --experimental_ui_max_stdouterr_bytes=1048576 bytes; skipping Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu failed to build

lyqaiym commented 1 year ago

execroot/mediapipe/bazel-out/_tmp/actions/stderr-230

duplicate symbol 'google::protobuf::Int64Value::_classdata' in: bazel-out/applebin_macos-darwin_x86_64-opt-exec-50AE0418-ST-cfb676c6944e/bin/external/com_google_protobuf/libprotobuf.lo(wrappers.pb.o) bazel-out/darwin-opt-exec-50AE0418/bin/external/com_google_protobuf/libprotobuf.lo(wrappers.pb.o) duplicate symbol 'google::protobuf::UInt32Value::_classdata' in: bazel-out/applebin_macos-darwin_x86_64-opt-exec-50AE0418-ST-cfb676c6944e/bin/external/com_google_protobuf/libprotobuf.lo(wrappers.pb.o) bazel-out/darwin-opt-exec-50AE0418/bin/external/com_google_protobuf/libprotobuf.lo(wrappers.pb.o) duplicate symbol 'google::protobuf::Int32Value::_classdata' in: bazel-out/applebin_macos-darwin_x86_64-opt-exec-50AE0418-ST-cfb676c6944e/bin/external/com_google_protobuf/libprotobuf.lo(wrappers.pb.o) bazel-out/darwin-opt-exec-50AE0418/bin/external/com_google_protobuf/libprotobuf.lo(wrappers.pb.o) ld: 3927 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error in child process '/usr/bin/xcrun'. 1

file hand_landmark_model_loader_graph_text_to_binary_graph-2.params multiple /libprotobuf.lo, libprotobuf_lite.lo

-Wl,-force_load,bazel-out/applebin_macos-darwin_x86_64-opt-exec-50AE0418-ST-cfb676c6944e/bin/mediapipe/framework/formats/libimage_format_cc_proto.lo -Wl,-force_load,bazel-out/applebin_macos-darwin_x86_64-opt-exec-50AE0418-ST-cfb676c6944e/bin/external/com_google_protobuf/libprotobuf.lo -Wl,-force_load,bazel-out/applebin_macos-darwin_x86_64-opt-exec-50AE0418-ST-cfb676c6944e/bin/external/com_google_protobuf/libprotobuf_lite.lo

-Wl,-force_load,bazel-out/darwin-opt-exec-50AE0418/bin/external/com_google_protobuf/libprotobuf.lo -Wl,-force_load,bazel-out/darwin-opt-exec-50AE0418/bin/external/com_google_protobuf/libprotobuf_lite.lo

lyqaiym commented 1 year ago

delete -Wl,-force_load,bazel-out/applebin_macos-darwin_x86_64

/usr/bin/sandbox-exec -f /private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/sandbox/darwin-sandbox/1153/sandbox.sb /var/tmp/_bazel_username/install/75b50ce753c66b4b3e83f1baa209bfd7/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/sandbox/darwin-sandbox/1153/stats.out' /private/var/tmp/_bazel_username/cc896c897553f99ee8ee66f7814f29cf/external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-opt-exec-50AE0418/bin/mediapipe/modules/palm_detection/palm_detection_model_loader_graph_text_to_binary_graph-2.params

generate palm_detection_model_loader_graph_text_to_binary_graph executable file

ayushgdev commented 1 year ago

Hello @lyqaiym This surely looks like a setup issue. Would you please look at this comment and check if you have made the necessary changes? Also, please use the SDK v30.0.3 and NDK v21.1.6352462.

lyqaiym commented 1 year ago

android_sdk_repository(name = "androidsdk", build_tools_version = "30.0.3",path = "/Users/username/Android/sdk") android_ndk_repository(name = "androidndk", api_level=21, path = "/Users/username/Android/sdk/ndk/21.1.6352462")

BTLDXX-x commented 1 year ago

hi @lyqaiym, had you upgrade xcode but not restart macos system? i did that yesterday, so i met this problem. now, i have restart macos system, the issue has gone. but i' m facing new issue:

ERROR: An error occurred during the fetch of repository 'android_gmaven_r8':
   Traceback (most recent call last):
    File "/private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/bazel_tools/tools/build_defs/repo/http.bzl", line 211, column 33, in _http_jar_impl
        download_info = ctx.download(
Error in download: java.io.IOException: Error downloading [https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar] to /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/android_gmaven_r8/jar/downloaded.jar: connect timed out
ERROR: /DEFAULT.WORKSPACE.SUFFIX:460:6: fetching http_jar rule //external:android_gmaven_r8: Traceback (most recent call last):
    File "/private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/bazel_tools/tools/build_defs/repo/http.bzl", line 211, column 33, in _http_jar_impl
        download_info = ctx.download(
Error in download: java.io.IOException: Error downloading [https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar] to /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/android_gmaven_r8/jar/downloaded.jar: connect timed out
INFO: Repository maven instantiated at:
  /Users/apple/MPProject/mediapipe/WORKSPACE:417:14: in <toplevel>
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/rules_jvm_external/defs.bzl:105:19: in maven_install
Repository rule coursier_fetch defined at:
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/rules_jvm_external/coursier.bzl:1009:33: in <toplevel>
INFO: Repository android_opencv instantiated at:
  /Users/apple/MPProject/mediapipe/WORKSPACE:358:13: in <toplevel>
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
INFO: Repository XNNPACK instantiated at:
  /Users/apple/MPProject/mediapipe/WORKSPACE:494:14: in <toplevel>
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/org_tensorflow/tensorflow/workspace2.bzl:972:21: in workspace
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/org_tensorflow/tensorflow/workspace2.bzl:144:20: in _tf_repositories
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/org_tensorflow/third_party/repo.bzl:136:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/org_tensorflow/third_party/repo.bzl:89:35: in <toplevel>
ERROR: /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/androidsdk/BUILD.bazel:13:25: @androidsdk//:d8_jar_import depends on @android_gmaven_r8//jar:jar in repository @android_gmaven_r8 which failed to fetch. no such package '@android_gmaven_r8//jar': java.io.IOException: Error downloading [https://maven.google.com/com/android/tools/r8/3.3.28/r8-3.3.28.jar] to /private/var/tmp/_bazel_apple/8bcb6d1f4c989e1d81eae00d06962091/external/android_gmaven_r8/jar/downloaded.jar: connect timed out
ERROR: Analysis of target '//mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu' failed; build aborted: 
INFO: Elapsed time: 56.340s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 873 targets co\
nfigured)
    Fetching https://github.com/...android-sdk.zip; 32.2 MiB (33,726,208B) 53s
    Fetching https://github.com/.../coursier.jar; 14.3 MiB (15,032,320B) 26s

i had try different vpn but failed.

ayushgdev commented 1 year ago

@lyqaiym Assuming the setup is correct, can you please run bazel clean --expunge and then follow the build process again?

fengyun21 commented 1 year ago

i try compile meidiapipe of 0.9.3 and had the same problem

but, i compiled mediapipe of 0.9.2.1 ,it's ok.

so, you can try the mediapipe of 0.9.2.1

lyqaiym commented 1 year ago

yes,v0.9.2.1 and bazel 5.2.0,it's ok.

fengyun21 commented 1 year ago

the mediapipe of v0.9.2.1 compiled ok,but the mediapipe of v0.9.3 compiled fail .

So is it the problem of v 0.9.3 ?

@ayushgdev

fengyun21 commented 1 year ago

yes,v0.9.2.1 and bazel 5.2.0,it's ok.

the version of xcode is 14.3 or 14.2 ?

lyqaiym commented 1 year ago

yes,v0.9.2.1 and bazel 5.2.0,it's ok.

the version of xcode is 14.3 or 14.2 ?

14.2

ayushgdev commented 1 year ago

hello @lyqaiym Both v0.9.3 and 0.9.2.1 are compiling fine. This seems to be setup issue. Listed below are the versions which I am using. Please ensure to have the same versions and try recompilation.

github-liuxu commented 1 year ago

hello @lyqaiym Both v0.9.3 and 0.9.2.1 are compiling fine. This seems to be setup issue. Listed below are the versions which I am using. Please ensure to have the same versions and try recompilation.

  • MacOS- 13.3.1
  • XCode - 14.1
  • Bazel - controlled by .bazelversion file in corresponding MediaPipe release- 5.2.0 in v0.9.2.1 and 6.1.1 in v0.9.3.0
  • openjdk version "11.0.18" 2023-01-17 LTS
  • opencv is installed via Option 1 in the docs
  • WORKSPACE file is edited as below (assuming opencv installation via Option 1):
diff --git a/WORKSPACE b/WORKSPACE
index 76089818..38510b3a 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -340,13 +340,13 @@ new_local_repository(
     # For local MacOS builds, the path should point to an opencv@3 installation.
     # If you edit the path here, you will also need to update the corresponding
     # prefix in "opencv_macos.BUILD".
-    path = "/usr/local",  # e.g. /usr/local/Cellar for HomeBrew
+    path = "/opt/homebrew",
 )

 new_local_repository(
     name = "macos_ffmpeg",
     build_file = "@//third_party:ffmpeg_macos.BUILD",
-    path = "/usr/local/opt/ffmpeg",
+    path = "/opt/homebrew/opt/ffmpeg",
 )

 new_local_repository(
@@ -596,3 +596,5 @@ http_archive(
     urls = ["https://github.com/halide/Halide/releases/download/v15.0.1/Halide-15.0.1-x86-64-windows-4c63f1befa1063184c5982b11b6a2cc17d4e5815.zip"],
     build_file = "@//third_party:halide.BUILD",
 )
+android_sdk_repository(name = "androidsdk", api_level=33, build_tools_version="30.0.3")
+android_ndk_repository(name = "androidndk", api_level=21)

How about xcode14.2?

fengyun21 commented 1 year ago

i used xcode 14.1, then, i try compile mediapipe v 0.9.3, but ,it failed

fengyun21 commented 1 year ago

mediapipe of v0.9.2.1 is compiled ok.

github-actions[bot] commented 1 year ago

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] commented 1 year ago

This issue was closed due to lack of activity after being marked stale for past 7 days.

google-ml-butler[bot] commented 1 year ago

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

lyqaiym commented 1 year ago

https://github.com/bazelbuild/bazel src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBaseRule.java the line 89,new version ExecutionTransitionFactory.create(),old version HostTransition.createFactory(). old is ok. ExecutionTransitionFactory.java change coreOptions.isHost = true; bazel-bin/src/bazel-dev

cancan101 commented 1 year ago

@lyqaiym, can you provide a bit more information on your solution. Where did you see that as a fix and do you know if there are plans to fix this issue upstream?