add support for MacOS with Apple Silicon M1
This commit is contained in:
		
							parent
							
								
									ae05ad04b3
								
							
						
					
					
						commit
						1608a9f041
					
				
							
								
								
									
										6
									
								
								.bazelrc
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								.bazelrc
									
									
									
									
									
								
							|  | @ -83,10 +83,16 @@ build:ios_fat --config=ios | ||||||
| build:ios_fat --ios_multi_cpus=armv7,arm64 | build:ios_fat --ios_multi_cpus=armv7,arm64 | ||||||
| build:ios_fat --watchos_cpus=armv7k | build:ios_fat --watchos_cpus=armv7k | ||||||
| 
 | 
 | ||||||
|  | # MacOS configs. | ||||||
| build:darwin_x86_64 --apple_platform_type=macos | build:darwin_x86_64 --apple_platform_type=macos | ||||||
| build:darwin_x86_64 --macos_minimum_os=10.12 | build:darwin_x86_64 --macos_minimum_os=10.12 | ||||||
| build:darwin_x86_64 --cpu=darwin_x86_64 | build:darwin_x86_64 --cpu=darwin_x86_64 | ||||||
| 
 | 
 | ||||||
|  | # MacOS Big Sur with Apple Silicon M1 | ||||||
|  | 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. | # This bazelrc file is meant to be written by a setup script. | ||||||
| try-import %workspace%/.configure.bazelrc | try-import %workspace%/.configure.bazelrc | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| 3.7.2 | 4.1.0 | ||||||
|  |  | ||||||
							
								
								
									
										65
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										65
									
								
								README.md
									
									
									
									
									
								
							|  | @ -100,6 +100,71 @@ The source code is hosted in the | ||||||
| run code search using | run code search using | ||||||
| [Google Open Source Code Search](https://cs.opensource.google/mediapipe/mediapipe). | [Google Open Source Code Search](https://cs.opensource.google/mediapipe/mediapipe). | ||||||
| 
 | 
 | ||||||
|  | ### Build on MacOS | ||||||
|  | 
 | ||||||
|  | #### CPU: Apple Silicon M1 | ||||||
|  | 1. Build "hello_world": | ||||||
|  | ```bash | ||||||
|  | bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --cpu darwin_arm64 mediapipe/examples/desktop/hello_world:hello_world | ||||||
|  | ``` | ||||||
|  | and run: | ||||||
|  | ```bash | ||||||
|  | export GLOG_logtostderr=1 | ||||||
|  | bazel-bin/mediapipe/examples/desktop/hello_world/hello_world | ||||||
|  | ``` | ||||||
|  | 2. Build all available examples under mediapipe/examples/desktop: | ||||||
|  | ```bash | ||||||
|  | bash build_macos_desktop_examples.sh --cpu m1 -b | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 3. Build and run one example app (e.g. mediapipe/examples/desktop/face_detection): | ||||||
|  | ``` | ||||||
|  | bash build_macos_desktop_examples.sh --cpu m1 --app face_detection -r | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | #### CPU: x86_64 | ||||||
|  | 1. Build "hello_world": | ||||||
|  | ```bash | ||||||
|  | bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --cpu darwin_x86_64 mediapipe/examples/desktop/hello_world:hello_world | ||||||
|  | ``` | ||||||
|  | and run: | ||||||
|  | ```bash | ||||||
|  | export GLOG_logtostderr=1 | ||||||
|  | bazel-bin/mediapipe/examples/desktop/hello_world/hello_world | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 2. Build all available examples under mediapipe/examples/desktop: | ||||||
|  | ```bash | ||||||
|  | bash build_macos_desktop_examples.sh --cpu x86_64 -b | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 3. Build and run one example app (e.g. mediapipe/examples/desktop/face_detection): | ||||||
|  | ``` | ||||||
|  | bash build_macos_desktop_examples.sh --cpu x86_64 --app face_detection -r | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | #### CPU: i386 | ||||||
|  | 1. Build "hello_world": | ||||||
|  | ```bash | ||||||
|  | bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 --cpu darwin_i386 mediapipe/examples/desktop/hello_world:hello_world | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | and run: | ||||||
|  | ```bash | ||||||
|  | export GLOG_logtostderr=1 | ||||||
|  | bazel-bin/mediapipe/examples/desktop/hello_world/hello_world | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 2. Build all available examples under mediapipe/examples/desktop: | ||||||
|  | ```bash | ||||||
|  | bash build_macos_desktop_examples.sh --cpu i386 -b | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 3. Build and run one example app (e.g. mediapipe/examples/desktop/face_detection): | ||||||
|  | ``` | ||||||
|  | bash build_macos_desktop_examples.sh --cpu i386 --app face_detection -r | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
| ## Publications | ## Publications | ||||||
| 
 | 
 | ||||||
| *   [MediaPipe Holistic - Simultaneous Face, Hand and Pose Prediction, on Device](https://ai.googleblog.com/2020/12/mediapipe-holistic-simultaneous-face.html) | *   [MediaPipe Holistic - Simultaneous Face, Hand and Pose Prediction, on Device](https://ai.googleblog.com/2020/12/mediapipe-holistic-simultaneous-face.html) | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								WORKSPACE
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								WORKSPACE
									
									
									
									
									
								
							|  | @ -1,5 +1,17 @@ | ||||||
| workspace(name = "mediapipe") | workspace(name = "mediapipe") | ||||||
| 
 | 
 | ||||||
|  | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||||||
|  | http_archive( | ||||||
|  |     name = "bazel_skylib", | ||||||
|  |     urls = [ | ||||||
|  |         "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", | ||||||
|  |         "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", | ||||||
|  |     ], | ||||||
|  |     sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", | ||||||
|  | ) | ||||||
|  | load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") | ||||||
|  | bazel_skylib_workspace() | ||||||
|  | 
 | ||||||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||||||
| 
 | 
 | ||||||
| http_archive( | http_archive( | ||||||
|  | @ -35,8 +47,8 @@ http_archive( | ||||||
| 
 | 
 | ||||||
| http_archive( | http_archive( | ||||||
|     name = "rules_cc", |     name = "rules_cc", | ||||||
|     strip_prefix = "rules_cc-master", |     strip_prefix = "rules_cc-main", | ||||||
|     urls = ["https://github.com/bazelbuild/rules_cc/archive/master.zip"], |     urls = ["https://github.com/bazelbuild/rules_cc/archive/main.zip"], | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| http_archive( | http_archive( | ||||||
|  |  | ||||||
|  | @ -75,7 +75,8 @@ alias( | ||||||
|     actual = select({ |     actual = select({ | ||||||
|         ":macos_i386": ":macos_i386", |         ":macos_i386": ":macos_i386", | ||||||
|         ":macos_x86_64": ":macos_x86_64", |         ":macos_x86_64": ":macos_x86_64", | ||||||
|         "//conditions:default": ":macos_i386",  # Arbitrarily chosen from above. |         ":macos_arm64": ":macos_arm64", | ||||||
|  |         "//conditions:default": ":macos_x86_64",  # Arbitrarily chosen from above. | ||||||
|     }), |     }), | ||||||
|     visibility = ["//visibility:public"], |     visibility = ["//visibility:public"], | ||||||
| ) | ) | ||||||
|  | @ -119,6 +120,15 @@ config_setting( | ||||||
|     visibility = ["//visibility:public"], |     visibility = ["//visibility:public"], | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | config_setting( | ||||||
|  |     name = "macos_arm64", | ||||||
|  |     values = { | ||||||
|  |         "apple_platform_type": "macos", | ||||||
|  |         "cpu": "darwin_arm64", | ||||||
|  |     }, | ||||||
|  |     visibility = ["//visibility:public"], | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| [ | [ | ||||||
|     config_setting( |     config_setting( | ||||||
|         name = arch, |         name = arch, | ||||||
|  |  | ||||||
|  | @ -26,7 +26,8 @@ | ||||||
| #include "mediapipe/framework/port/status.h" | #include "mediapipe/framework/port/status.h" | ||||||
| 
 | 
 | ||||||
| #ifdef __APPLE__ | #ifdef __APPLE__ | ||||||
| #define AUTORELEASEPOOL @autoreleasepool | // #define AUTORELEASEPOOL @autoreleasepool
 | ||||||
|  | #define AUTORELEASEPOOL | ||||||
| #else | #else | ||||||
| #define AUTORELEASEPOOL | #define AUTORELEASEPOOL | ||||||
| #endif  // __APPLE__
 | #endif  // __APPLE__
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user