TensorFlow Android端编译过程记录
分享一下TensorFlow Android端编译全过程
TensorFlow iOS 端编译过程
翻墙,一定要翻墙,而且要保证下载速度的翻墙!
首先说明:我是深度学习小白,关于深度学习TensorFlow不了解,因为公司需要将图像识别模型放在移动端设备上使用,所以才尝试编译它,万幸最后成功了!
参照
TensorFlow GitHub中的Android端编译指导
当然,编译过程中产生的问题都可以在issues中找找
编译环境
系统:mac os 10.14
bazel: 0.24.1
TensorFlow:1.14.0
Android SDK:23
Android NDK:17c
Python:3.6.3
jdk:1.8
环境搭建
1、安装Bazel 0.24.1
按照官网mac 上步骤安装即可,为什么安装0.24.1,因为其他的我试了,不合适。
2、安装jdk1.8
3、安装python 3.6.3
4、安装Android SDK 23
使用Android Studio或者官网下载安装即可
5、安装Android NDK
在官网下载或百度NDK 17下载后解压到sdk安装目录
为什么一定要是 17c ,因为其他的我都试了,然而只是浪费感情。
6、下载TensorFlow 1.14.0 release版
选择 1.14.0 的原因是,此版本我在mac上编译iOS和Android都成功了
PS:其他版本我也尝试过,编译过程中缺少文件。。。。
编译过程
1、清空编译缓存
如果之前编译过,最好是用一下,如果不用,不知道会出什么问题。
bazel clean --expunge
2、configure 配置TensorFlow编译过程中需要的编译环境
按照自己电脑配置情况按照步骤进行配置即可,以下是我的mac上的一些配置:
终端输入:
./configure
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.24.1 installed.
Please specify the location of python. [Default is /usr/local/opt/python@2/bin/python2.7]: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Found possible Python library paths:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Please input the desired Python library path to use. Default is [/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages]
Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
No XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.
Do you wish to build TensorFlow with ROCm support? [y/N]: n
No ROCm support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: n
No CUDA support will be enabled for TensorFlow.
Do you wish to download a fresh release of clang? (Experimental) [y/N]: n
Clang will not be downloaded.
Do you wish to build TensorFlow with MPI support? [y/N]: n
No MPI support will be enabled for TensorFlow.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]:
Would