Skip to content

Want to build tensorflow for android but stuck at this problem. #11279

Closed

Description

@RohitDulam

OS Platform and Distribution : Windows 10
Bazel version :0.5.2

C:\Users\dulam\tensorflow>bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so
ERROR: C:/users/dulam/tensorflow/tensorflow/core/BUILD:1415:1: no such target '//tensorflow/tools/git:gen/spec.json': target 'gen/spec.json' not declared in package 'tensorflow/tools/git' defined by C:/users/dulam/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'.
ERROR: C:/users/dulam/tensorflow/tensorflow/core/BUILD:1415:1: no such target '//tensorflow/tools/git:gen/head': target 'gen/head' not declared in package 'tensorflow/tools/git' defined by C:/users/dulam/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'.
ERROR: C:/users/dulam/tensorflow/tensorflow/core/BUILD:1415:1: no such target '//tensorflow/tools/git:gen/branch_ref': target 'gen/branch_ref' not declared in package 'tensorflow/tools/git' defined by C:/users/dulam/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'.
ERROR: Analysis of target '//tensorflow/contrib/android:libtensorflow_inference.so' failed; build aborted.

Activity

  1. drpngx commented on Jul 4, 2017

    @drpngx
    Contributor

    For windows, it's best that you use the CMake solution right now, in contrib/cmake.

  2. RohitDulam commented on Jul 4, 2017

    @RohitDulam
    Author

    I'm new to this, can you give me a reference link that explains the procedure you just said. @drpngx

  3. drpngx commented on Jul 4, 2017

    @drpngx
    Contributor

    Oh, wait, do you want to cross-compile from windows to android?

  4. RohitDulam commented on Jul 4, 2017

    @RohitDulam
    Author

    I want to train a classifier on my windows machine and use it in an android application.

  5. drpngx commented on Jul 4, 2017

    @drpngx
    Contributor

    Ah, OK. I'd recommend downloading the binary for windows, building your model, then downloading the binary for android, then copying the binaries over. There is no HOWTO AFAIK.

    @mhyttsten might have a clue. If not, that might be a good document to have.

  6. jubjamie commented on Jul 5, 2017

    @jubjamie
    Contributor

    You can just copy the binaries into the project. I just got them from the nightly and put them into my libs folder in my project. I would recommend looking at the android demo app here for more information: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android

    @drpngx when I started with the android stuff a few months ago it was incredibly painful getting it to work, especially on windows. I think a proper howto on getting your android project set up with Tensorflow would be handy. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/android/README.md is a good start but I think some clear documentation and/or tutorial would be much appreciated!

  7. andydavis1 commented on Jul 5, 2017

    @andydavis1
    Contributor

    assigned to add documentation for a how-to on this.

  8. andrewharp commented on Jul 10, 2017

    @andrewharp
    Contributor

    @RohitDulam It's currently not possible to build Android TF on Windows directly using Bazel (this is a Bazel limitation). See #6385 for details and workarounds. The preferred method of using TF on Android is the AAR distribution which allows integration with a few lines of configuration. You can also manually download the prebuilt binaries as others suggest.

    @jubjamie Agreed that a more comprehensive official walkthrough would be useful, this is something we plan on adding.

  9. tensorflowbutler commented on Dec 20, 2017

    @tensorflowbutler
    Member

    It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly.

  10. drpngx commented on Dec 20, 2017

    @drpngx
    Contributor

    We seem to have revamped the build to split it into multiple libraries. Please check with the newest version to see if the problem persists.

  11. dr4b commented on Dec 21, 2017

    @dr4b

    Right -- I think everything current about building for Android is in https://www.tensorflow.org/mobile/ now.

  12. tensorflowbutler commented on Jan 4, 2018

    @tensorflowbutler
    Member

    It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly.

  13. drpngx commented on Jan 4, 2018

    @drpngx
    Contributor

    Closing since it seems to be working now.

  14. BarMazal commented on Mar 16, 2018

    @BarMazal

    Hi,
    I'm on windows. The android example runs pretty straight forward, however using this build the native libraries are pre-built and stripped of symbols and I can't use them to link other native C++ code that uses either the C++ or C TF APIs.
    Do you have any suggestions other than use a different operation system for the compilation?

    Thanks.

  15. andrewharp commented on Mar 16, 2018

    @andrewharp
    Contributor

    @BarMazal you might try the Linux for Windows workaround outlined in #6385 to build the custom binaries you need

  16. cusitkhan commented on Oct 24, 2018

    @cusitkhan

    drpngx i am building .so file using bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a and i faced this probelm form two weeks
    ERROR: C:/users/sabir-pc/_bazel_sabir-pc/zp6kp3ov/external/com_google_absl/absl/strings/BUILD.bazel:32:1: C++ compilation of rule '@com_google_absl//absl/strings:strings' failed (Exit 1)
    In file included from external/com_google_absl/absl/strings/str_cat.cc:15:
    In file included from external/com_google_absl\absl/strings/str_cat.h:62:
    In file included from external/com_google_absl\absl/strings/numbers.h:37:
    In file included from external/com_google_absl\absl/numeric/int128.h:29:
    In file included from external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include\cmath:305:
    In file included from external/androidndk/ndk/sources/android/support/include\math.h:32:
    external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include\math.h:1302:93: error: no member named 'log2f' in the global namespace
    inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
    ~~^
    external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include\math.h:1303:93: error: no member named 'log2l' in the global namespace
    inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
    ~~^
    external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include\math.h:1308:38: error: call to 'log2' is ambiguous
    log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
    ^~~~~~
    external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include\math.h:1302:46: note: candidate function
    inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
    ^
    external/androidndk/ndk/sources/cxx-stl/llvm-libc++/include\math.h:1303:46: note: candidate function
    inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
    ^
    3 errors generated.
    Target //tensorflow/contrib/android:libtensorflow_inference.so failed to build
    Use --verbose_failures to see the command lines of failed build steps.
    INFO: Elapsed time: 212.615s, Critical Path: 18.57s
    INFO: 213 processes: 213 local.
    FAILED: Build did NOT complete successfully
    please help i am stuck in my FYP

  17. cusitkhan commented on Oct 24, 2018

    @cusitkhan

    i am building libtensorflow_inference.so file using build but it will give me the error
    compilation of rule '@com_google_absl//absl/strings:strings' failed (Exit 1)
    please tensorflow member help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions