1. Download TensorFlow
$ git clone https://github.com/tensorflow/tensorflow.git
As of writing this post, I'm at
commit 70e9708e234c86632e1f24b45e058cb87f8abe29
Date: Thu May 7 09:32:16 2020 -0700
2. Install Android SDK
https://developer.android.com/studio
The default location is ~/library/Android/Sdk
3. Extract Android NDK
https://developer.android.com/ndk/downloads
Extract this in ~/library/Android/Sdk/ndk-bundle
4. Install Bazel
TF configure requires a very specific Bazel version.
It is not "higher than X", but a specific version X.
As of this writing, it's Bazel 3.0.0.
https://docs.bazel.build/versions/master/install-os-x.html
It should be at ~/bin/bazel
5. Configure TensorFlow
$ cd tensorflow
$ ./configure
For most of those, go with the default until you see:
> Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: y
Configuration finished
6. Install numpy
$ pip3 install numpy
Successfully installed numpy-1.18.4
7. Build a target in TFLite
When I tried to build:
$ bazel build --config android_arm64 tensorflow/lite/delegates/gpu:delegate
I was greeted with a system dialog that said:
“clang” cannot be opened because the developer cannot be verified.
The solution for this is at:
https://stackoverflow.com/questions/58390545/cannot-use-old-ndk-android-ndk-r17c-after-catalina-upgrade-due-to-new-security
The first answer should fix the problem.
Don't forget to switch to the "General" tab where the "allow" button should pop.
You have to go through a handful of files incl. ar, ld, and libc++-related files.
This was a couple of hours wasted, and I wanted to save everyone else's time.
Comments
Post a Comment