Linux下編譯tensorflow r1.12的libtensorflow_inference.so

1. 編譯環境:

1) bazel

    version: 0.18.1

2) NDK 

     version: android-ndk-r14b

     將android-ndk-r14b/platforms的android-23重命名爲android-14,注意備份原有的android-14

3) SDK

     api_level: 23

     build-tools: 28.0.2

2. ./configure,CPU版可參考以下配置

build --action_env PYTHON_BIN_PATH="XXX/anaconda3/bin/python"
build --action_env PYTHON_LIB_PATH="XXX/anaconda3/lib/python3.6/site-packages"
build --python_path="XXX/anaconda3/bin/python"
build:ignite --define with_ignite_support=true
build:xla --define with_xla_support=true
build --action_env TF_NEED_OPENCL_SYCL="0"
build --action_env TF_NEED_ROCM="0"
build --action_env TF_NEED_CUDA="0"
build --action_env TF_DOWNLOAD_CLANG="0"
build:opt --copt=-march=native
build:opt --host_copt=-march=native
build:opt --define with_default_optimizations=true
build:v2 --define=tf_api_version=2
build --action_env ANDROID_NDK_HOME="XXX/android-ndk-r14b"
build --action_env ANDROID_NDK_API_LEVEL="14"
build --action_env ANDROID_BUILD_TOOLS_VERSION="28.0.2"
build --action_env ANDROID_SDK_API_LEVEL="23"
build --action_env ANDROID_SDK_HOME="XXX/android-sdk-linux"

3. 編譯

https://www.jianshu.com/p/056ba3cbf02a

提示:若有以下報錯:

error: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

可在編譯命令中加入--cxxopt=-std=c++11

eg. bazel build --cxxopt=-std=c++11 -c opt --copt="-DSELECTIVE_REGISTRATION" --copt="-DSUPPORT_SELECTIVE_REGISTRATION" //tensorflow/contrib/android:libtensorflow_inference.so --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --verbose_failures

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章