mediapipe
mediapipe copied to clipboard
Mac M1 Tensorflow Set Up
"ERROR: While resolving toolchains for target @org_tensorflow//tensorflow/tools/git:gen_git_source: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions. ERROR: Analysis of target '//mediapipe/examples/ios/facedetectioncpu:facedetectioncpu' failed; build aborted: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions."
I am trying to follow instructions here to set up tensorflow using the new mac m1 chip: https://github.com/apple/tensorflow_macos
However, I am still having no luck with initial set up for media pipe.
Have I written custom code: No OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Mac OS 11.0.1 Bazel version:nbazel 3.7.2-homebrew Xcode & Tulsi version (if issue is related to building in mobile dev enviroment): 12.3 Tusli 0.20210106.88 Exact steps to reproduce: ./build_ios_examples.sh -d out_dir --nostrip
MediaPipe with its TensorFlow dependence needs Bazel to build everything from scratch. I don't think bazel already supports M1 yet: https://github.com/bazelbuild/bazel/issues/11628.
https://github.com/apple/tensorflow_macos requires the users to use https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha1/tensorflow_macos-0.1alpha1.tar.gz, which is not the "official" version of tensorflow.
It looks like the tensorflow team has added M1 support. https://github.com/tensorflow/tensorflow/issues/46178
Is there a workaround to not have to wait for bazel compatibility?
I took a look at https://github.com/tensorflow/tensorflow/commit/e687cab61615a95b8aea79120c9f168d4cc30955. My conclusion is the mediapipe repo needs some config changes for supporting Apple Silicon. For example, the repo needs to add a config for "macos_arm64" config_setting like the one it has for macos_x86_64. Also, it needs to point to the latest TF version that supports Apple Silicon.
Do you have an ETA when the repo will be updated with the config changes? This blocks any integration from the m1 chip
Any update on M1 support?
also have an error on m1
Feels like barely anyone else has an M1 mac, has anyone got a fix for this?
I am on M1 and its failing to build still
Yea, not yet I suppose, I cannot install nuget too as it requires x86_64 architecture, I just use windows for now and my friend works on intel macbook
I confirmed that hand_tracking_cpu
works on Mac mini (M1, 2020) (macOS Big Sur 11.6) with the following patch applied.
diff --git a/.bazelrc b/.bazelrc
index 37a0bc1..7d7e159 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -87,6 +87,11 @@ build:darwin_x86_64 --apple_platform_type=macos
build:darwin_x86_64 --macos_minimum_os=10.12
build:darwin_x86_64 --cpu=darwin_x86_64
+# May not be necessary
+build:darwin_arm64 --apple_platform_type=macos
+build:darwin_arm64 --macos_minimum_os=10.16
+build:darwin_arm64 --cpu=darwin_arm64
+
# This bazelrc file is meant to be written by a setup script.
try-import %workspace%/.configure.bazelrc
diff --git a/.bazelversion b/.bazelversion
index 0b2eb36..fae6e3d 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-3.7.2
+4.2.1
diff --git a/WORKSPACE b/WORKSPACE
index c2aaca6..30afd92 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -200,7 +200,7 @@ new_local_repository(
new_local_repository(
name = "macos_opencv",
build_file = "@//third_party:opencv_macos.BUILD",
- path = "/usr/local/opt/opencv@3",
+ path = "/opt/homebrew/opt/opencv@3",
)
new_local_repository(
diff --git a/mediapipe/BUILD b/mediapipe/BUILD
index 1171ea6..72e4208 100644
--- a/mediapipe/BUILD
+++ b/mediapipe/BUILD
@@ -74,6 +74,7 @@ alias(
name = "macos",
actual = select({
":macos_i386": ":macos_i386",
+ ":macos_arm64": ":macos_arm64",
":macos_x86_64": ":macos_x86_64",
"//conditions:default": ":macos_i386", # Arbitrarily chosen from above.
}),
@@ -110,6 +111,15 @@ config_setting(
visibility = ["//visibility:public"],
)
+config_setting(
+ name = "macos_arm64",
+ values = {
+ "apple_platform_type": "macos",
+ "cpu": "darwin_arm64",
+ },
+ visibility = ["//visibility:public"],
+)
+
config_setting(
name = "macos_x86_64",
values = {
The exact command can be found here.
It seems that a similar patch is already submitted as a PR. https://github.com/google/mediapipe/pull/2591
@homuler Thank you for the recommendations; I've made those changes and I'm still having issues. Additionally, the PR you linked has issues: It still references bazel 3.7.2. Additionally in your changes, I had to also change the reference to ffmpeg in WORKSPACE.
I installed the latest bazel (4.2.2) through brew, then updated .bazelversion to reflect that, but when I tried to run the helloworld, I ended up with:
"dyld[70906]: symbol not found in flat namespace '_CFRelease'"
Any further advice?
It has been almost a year does anyone have a solution to this?
I followed the changes in https://github.com/google/mediapipe/pull/2591/files with slight differences in OpenCV and FFMPEG versions and still got build errors.
In file included from mediapipe/framework/formats/image_frame_opencv.cc:15:
In file included from ./mediapipe/framework/formats/image_frame_opencv.h:20:
./mediapipe/framework/port/opencv_core_inc.h:18:10: fatal error: 'opencv2/core/version.hpp' file not found
#include <opencv2/core/version.hpp>
I would prefer not to use a unity plugin.
This doesn't solve the issue of running mediapipe on M1 metal, but you can get mediapipe to run on your M1 hardware by using rosetta, as described in this comment. (Read the rest of the comments before diving in. To solve the homebrew permissions problem in /usr/local
you can refer to this SO answer)
@homuler Thank you for the recommendations; I've made those changes and I'm still having issues. Additionally, the PR you linked has issues: It still references bazel 3.7.2. Additionally in your changes, I had to also change the reference to ffmpeg in WORKSPACE.
I installed the latest bazel (4.2.2) through brew, then updated .bazelversion to reflect that, but when I tried to run the helloworld, I ended up with:
"dyld[70906]: symbol not found in flat namespace '_CFRelease'"
Any further advice?
same problem here。 any solutions?
I wonder why they don't reflect any of this limitation on the installation page at the TensorFlow website. They just say this:
macOS 10.12.6 (Sierra) or later (no GPU support)
Which seems to contradict the actual status if I'm following. What do you think?
related: #3277 (community M1 wheels)
Hi @mgebhard , Apple M1 supports in latest release , could you check, verify and close this issue.
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.
@sureshdagooglecom
pip install mediapipe
still gives
ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none)
ERROR: No matching distribution found for mediapipe
I am on Python 3.9.13 and pip 22.1.2.
Closing as stale. Please reopen if you'd like to work on this further.
Hi @mgebhard , what is the error you are facing w.r.t above issue and please share the error logs.
@sureshdagooglecom
pip install mediapipe
still givesERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none) ERROR: No matching distribution found for mediapipe
I am on Python 3.9.13 and pip 22.1.2.
Unfortunately, we still do not have native Python wheels. You can run Python under Rosetta.
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.
thanks! any timeline or eta for when native wheels will be built?
Unfortunately, we don't have an ETA for this at this point.
@schmidt-sebastian Can you enumerate the tasks/gaps that you are aware of for this support to be completed?
I don't think I can go into much detail here, but it is an infrastructure issue on our end.
This patch seems to work https://github.com/cansik/mediapipe-silicon . Would it be possible to implement this so there can be a wheel for people to download without having to run through rosetta.
In the meanwhile for people wanting to install mediapipe I suggest installing one of the prebuilt binaries with pip install
https://github.com/cansik/mediapipe-silicon/releases/tag/v0.8.10.1
For me pip install mediapipe_silicon-0.8.10.1-cp39-cp39-macosx_12_0_arm64.whl
worked.