Add doc on building TFLite libraries using Docker
PiperOrigin-RevId: 314424779 Change-Id: I2524a6f75472aecfa429dc21323e275762444c6c
This commit is contained in:
parent
408cb226f4
commit
7cbb7cc2f6
tensorflow
@ -99,7 +99,60 @@ example, you may be building a custom binary that includes
|
||||
[operations selected from TensorFlow](https://www.tensorflow.org/lite/guide/ops_select),
|
||||
or you may wish to make local changes to TensorFlow Lite.
|
||||
|
||||
#### Install Bazel and Android Prerequisites
|
||||
#### Set up build environment using Docker
|
||||
|
||||
* Download the Docker file. By downloading the Docker file, you agree that the
|
||||
following terms of service govern your use thereof:
|
||||
|
||||
*By clicking to accept, you hereby agree that all use of the Android Studio and
|
||||
Android Native Development Kit will be governed by the Android Software
|
||||
Development Kit License Agreement available at
|
||||
https://developer.android.com/studio/terms (such URL may be updated or changed
|
||||
by Google from time to time).*
|
||||
|
||||
{% dynamic if 'tflite-android-tos' in user.acknowledged_walls and request.tld !=
|
||||
'cn' %} You can download the Docker file
|
||||
<a href="https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/dockerfiles/tflite-android.Dockerfile">here</a>
|
||||
{% dynamic else %} You must acknowledge the terms of service to download the
|
||||
file.
|
||||
<a class="button button-blue devsite-acknowledgement-link" data-globally-unique-wall-id="tflite-android-tos">Acknowledge</a>
|
||||
{% dynamic endif %}
|
||||
|
||||
* You can optionally change the Android SDK or NDK version. Put the downloaded
|
||||
Docker file in an empty folder and build your docker image by running:
|
||||
|
||||
```shell
|
||||
docker build . -t tflite-builder -f tflite-android.Dockerfile
|
||||
```
|
||||
|
||||
* Start the docker container interactively by mounting your current folder to
|
||||
/tmp inside the container (note that /tensorflow_src is the TensorFlow
|
||||
repository inside the container):
|
||||
|
||||
```shell
|
||||
docker run -it -v $PWD:/tmp tflite-builder bash
|
||||
```
|
||||
|
||||
If you use PowerShell on Windows, replace "$PWD" with "pwd".
|
||||
|
||||
If you would like to use a TensorFlow repository on the host, mount that host
|
||||
directory instead (-v hostDir:/tmp).
|
||||
|
||||
* Once you are inside the container, you can run the following to download
|
||||
additional Android tools and libraries (note that you may need to accept the
|
||||
license):
|
||||
|
||||
```shell
|
||||
android update sdk --no-ui -a --filter tools,platform-tools,android-${ANDROID_API_LEVEL},build-tools-${ANDROID_BUILD_TOOLS_VERSION}’
|
||||
```
|
||||
|
||||
You can now proceed to the "Build and Install" section. After you are finished
|
||||
building the libraries, you can copy them to /tmp inside the container so that
|
||||
you can access them on the host.
|
||||
|
||||
#### Set up build environment without Docker
|
||||
|
||||
##### Install Bazel and Android Prerequisites
|
||||
|
||||
Bazel is the primary build system for TensorFlow. To build with it, you must
|
||||
have it and the Android NDK and SDK installed on your system.
|
||||
@ -114,7 +167,7 @@ have it and the Android NDK and SDK installed on your system.
|
||||
[Android Studio](https://developer.android.com/studio/index.html). Build
|
||||
tools API >= 23 is the recommended version for building TensorFlow Lite.
|
||||
|
||||
#### Configure WORKSPACE and .bazelrc
|
||||
##### Configure WORKSPACE and .bazelrc
|
||||
|
||||
Run the `./configure` script in the root TensorFlow checkout directory, and
|
||||
answer "Yes" when the script asks to interactively configure the `./WORKSPACE`
|
||||
|
33
tensorflow/tools/dockerfiles/tflite-android.Dockerfile
Normal file
33
tensorflow/tools/dockerfiles/tflite-android.Dockerfile
Normal file
@ -0,0 +1,33 @@
|
||||
FROM tensorflow/tensorflow:devel
|
||||
|
||||
ENV ANDROID_DEV_HOME /android
|
||||
RUN mkdir -p ${ANDROID_DEV_HOME}
|
||||
|
||||
# Install Android SDK.
|
||||
ENV ANDROID_SDK_FILENAME tools_r25.2.5-linux.zip
|
||||
ENV ANDROID_SDK_URL https://dl.google.com/android/repository/${ANDROID_SDK_FILENAME}
|
||||
ENV ANDROID_API_LEVEL 23
|
||||
ENV ANDROID_NDK_API_LEVEL 18
|
||||
# Build Tools Version liable to change.
|
||||
ENV ANDROID_BUILD_TOOLS_VERSION 28.0.0
|
||||
ENV ANDROID_SDK_HOME ${ANDROID_DEV_HOME}/sdk
|
||||
ENV PATH ${PATH}:${ANDROID_SDK_HOME}/tools:${ANDROID_SDK_HOME}/platform-tools
|
||||
RUN cd ${ANDROID_DEV_HOME} && \
|
||||
wget -q ${ANDROID_SDK_URL} && \
|
||||
unzip ${ANDROID_SDK_FILENAME} -d android-sdk-linux && \
|
||||
rm ${ANDROID_SDK_FILENAME} && \
|
||||
bash -c "ln -s ${ANDROID_DEV_HOME}/android-sdk-* ${ANDROID_SDK_HOME}"
|
||||
|
||||
# Install Android NDK.
|
||||
ENV ANDROID_NDK_FILENAME android-ndk-r17c-linux-x86_64.zip
|
||||
ENV ANDROID_NDK_URL https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}
|
||||
ENV ANDROID_NDK_HOME ${ANDROID_DEV_HOME}/ndk
|
||||
ENV PATH ${PATH}:${ANDROID_NDK_HOME}
|
||||
RUN cd ${ANDROID_DEV_HOME} && \
|
||||
wget -q ${ANDROID_NDK_URL} && \
|
||||
unzip ${ANDROID_NDK_FILENAME} -d ${ANDROID_DEV_HOME} && \
|
||||
rm ${ANDROID_NDK_FILENAME} && \
|
||||
bash -c "ln -s ${ANDROID_DEV_HOME}/android-ndk-* ${ANDROID_NDK_HOME}"
|
||||
|
||||
# Make android ndk executable to all users.
|
||||
RUN chmod -R go=u ${ANDROID_DEV_HOME}
|
Loading…
Reference in New Issue
Block a user