Android demo: unable to build with Bazel, could not read RELEASE.TXT #3175

Closed
cardshuffle opened this Issue Jul 4, 2016 · 19 comments

Projects

None yet

5 participants

@cardshuffle
cardshuffle commented Jul 4, 2016 edited

Environment info

Operating System: Ubuntu 14.04 LTS 64-bit

Installed version of CUDA and cuDNN: none (not using GPU)

Steps to reproduce

Note: TensorFlow was installed previously.

  1. Install Bazel as instructed here: http://www.bazel.io/docs/install.html#install-on-ubuntu
  2. Install Android Studio (which includes the SDK).
  3. Install Android NDK through the Android Studio SDK Manager.
  4. Download and unzip the TensorFlow graph as instructed here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/README.md
  5. Uncomment the Android entries in the WORKSPACE file and add in paths to the SDK and NDK (in my case, these were /home/me/Android/Sdk and /home/me/android-studio/android-studio/plugins/android-ndk)
  6. Run $ bazel build //tensorflow/examples/android:tensorflow_demo

What have you tried?

  1. I've looked around, and my understanding is that the RELEASE.TXT file is not included in the most recent version of the Android NDK. Since the NDK installed via Android Studio is a .jar file, I wasn't sure what to do with that, so I went to the path indicated by the terminal log and created a blank RELEASE.TXT file. This made no difference.
  2. According to #1468, it can be resolved by downgrading to an earlier version of the NDK which contains RELEASE.TXT. I downloaded the version of Bazel (for Linux) from the links given, but the downloaded file is a .bin, which is unusable to me. As such, I found this solution to be a dead end.
  3. Commenting out the NDK entry is said to resolve the issue, but I haven't tried this yet, since I don't know if it'll cause more complications down the road.

Logs or other output that would be helpful

ERROR: no such package '@androidndk//': Could not read RELEASE.TXT in Android NDK: /home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk/RELEASE.TXT (No such file or directory).
ERROR: no such package '@androidndk//': Could not read RELEASE.TXT in Android NDK: /home/me/.cache/bazel/_bazel_me/f3471be34d1e62bf21975aa777cedaa3/external/androidndk/ndk/RELEASE.TXT (No such file or directory).

Is there another way to resolve this issue without downgrading or commenting out the NDK entry? If not, how can I install a previous version of Android NDK? Thanks in advance.

@lukesleeman

This seems to be a duplicate of #1468
Unfortunately #1468 was closed by the submitter after people suggested he download an old version of the NDK.

The workaround helps the person that submitted #1468, but the issue with the TensorFlow build system remains ...

@andrewharp
Member

@cardshuffle Which version of Bazel did you install? 0.3.0 is required for NDK 11 support. Otherwise you'll need to use Android NDK r10e (links in #1468) as @lukesleeman suggests.

@aselle
Member
aselle commented Jul 15, 2016

Automatically closing due to lack of recent activity. Please reopen when further information becomes available.

@aselle aselle closed this Jul 15, 2016
@cardshuffle
cardshuffle commented Jul 18, 2016 edited

@lukesleeman #1468 was the issue I linked to, and I already discussed how I tried the solutions suggested there.
@andrewharp I installed version 0.3.0 as confirmed by bazel version. This is the log output:

Build label: 0.3.0
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel /BazelServer_deploy.jar
Build time: Fri Jun 10 11:38:23 2016 (1465558703)
Build timestamp: 1465558703
Build timestamp as int: 1465558703

Also, a correction: I mistakenly said that #1468 suggested downgrading Bazel where it was actually the Android NDK, and I just fixed it. In the end, I still have not resolved this issue. Could this be reopened?

@aselle aselle reopened this Jul 18, 2016
@andrewharp
Member
andrewharp commented Jul 18, 2016 edited

@cardshuffle
Can you please clarify what issue "it" was that you fixed by downgrading your ndk, what version you downgraded to, and what issue still remains?

I was just able to clone the TF repo and build the tensorflow demo using NDK r11c and Bazel 0.3.0 on Ubuntu. The RELEASE.TXT issues should no longer occur with this version combination.

It's possible that Android Studio has downloaded a different variant for you, though -- Bazel does not officially support r12 at the moment. You could try manually downloading r11c here: http://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip and see if that works.

If that doesn't help, can you please paste the NDK entry from your WORKSPACE?

@andrewharp andrewharp self-assigned this Jul 18, 2016
@cardshuffle

@andrewharp I didn't downgrade the NDK (at the time of that post). What I "fixed" was my initial post in this thread, when I mistakenly said Bazel instead of NDK. I also stated in my initial post that I was unable to downgrade to NDK using the links provided in #1468 (I tried to downgrade to r10e). Sorry if my wording was confusing.

I downloaded the NDK r11c using the link you provided, unzipped it to the Documents directory, and modified the WORKSPACE file:

android_ndk_repository(
    name="androidndk",
    path="/home/me/Documents/android-ndk-r11c",
    api_level=21)

Then I ran the Bazel build command again, and I got this error:

ERROR: /home/me/tf/tensorflow/tensorflow/examples/android/BUILD:12:1: error loading package 'tensorflow/core': Extension file not found. Unable to load package for '//google/protobuf:protobuf.bzl': BUILD file not found on package path and referenced by '//tensorflow/examples/android:libtensorflow_demo.so'.
ERROR: Analysis of target '//tensorflow/examples/android:tensorflow_demo' failed; build aborted.
INFO: Elapsed time: 0.491s
@andrewharp
Member
andrewharp commented Jul 19, 2016 edited

Did you git clone with the --recurse_submodules option?

@cardshuffle

@andrewharp When I initially installed TensorFlow and cloned the repository, I didn't use --recursive, but I just re-cloned it in a new folder using --recursive, and redid all the steps (excluding installation of the SDK/NDK/Bazel), up to the Bazel build. However, I got this output:

WARNING: /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/protobuf/WORKSPACE:1: Workspace name in /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/protobuf/WORKSPACE (@__main__) does not match the name given in the repository's definition (@protobuf); this will cause a build error in future versions.
WARNING: /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/highwayhash/WORKSPACE:1: Workspace name in /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/highwayhash/WORKSPACE (@__main__) does not match the name given in the repository's definition (@highwayhash); this will cause a build error in future versions.
WARNING: /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/re2/WORKSPACE:1: Workspace name in /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/re2/WORKSPACE (@__main__) does not match the name given in the repository's definition (@re2); this will cause a build error in future versions.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:avgpooling_op.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:bounds_check.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_activations.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_attention.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_backward_cuboid_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_backward_spatial_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_cuboid_convolution.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_patch_3d.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_pooling.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_softmax.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_spatial_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:maxpooling_op.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:ops_util.cc' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:ops_util.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:pooling_ops_common.cc' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:pooling_ops_common.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_entry.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_scorer.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_search.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_decoder.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /home/me/tf_m/tensorflow/tensorflow/core/BUILD:619:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_loss_util.h' directly. You should either move the file to this package or depend on an appropriate rule there.
INFO: Found 1 target...
ERROR: missing input file '@androidsdk//:platforms/android-23/android.jar'.
ERROR: /home/me/tf_m/tensorflow/tensorflow/examples/android/BUILD:47:1: //tensorflow/examples/android:tensorflow_demo: missing input file '@androidsdk//:platforms/android-23/android.jar'.
Target //tensorflow/examples/android:tensorflow_demo failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/me/tf_m/tensorflow/tensorflow/examples/android/BUILD:47:1 1 input file(s) do not exist.
INFO: Elapsed time: 11.984s, Critical Path: 0.27s
@andrewharp
Member

Does platforms/android-23/android.jar exist in your sdk directory? Can you paste the WORKSPACE entry for your sdk and ndk please?

@cardshuffle

No, but the path platforms/android-24/android.jar does. This is my WORKSPACE entry:

android_sdk_repository(
    name = "androidsdk",
    api_level = 23,
    build_tools_version = "23.0.1",
    # Replace with path to Android SDK on your system
    path = "/home/me/Android/Sdk",
)

android_ndk_repository(
    name="androidndk",
    path="/home/me/Documents/android-ndk-r11c",
    api_level=21)

I suspect that the error is because the file says that the api is version 23 whereas I think I have version 24 installed. Is this the case? If so, then will I have to change the version of the build tools too?

@andrewharp
Member

Sounds like it. You can use /home/me/Android/Sdk/tools/android to confirm.

There's no problem having multiple Android api levels installed in your SDK, so you can use the android tool to install 23, or just change WORKSPACE to match what you have.

@cardshuffle

This is the error now:

ERROR: /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/external/gif_archive/BUILD:14:1: C++ compilation of rule '@gif_archive//:gif' failed: namespace-sandbox failed: error executing command /home/me/.cache/bazel/_bazel_me/95be766f297ed076701dc5f5e00e0a6b/execroot/tensorflow/_bin/namespace-sandbox ... (remaining 46 argument(s) skipped).
external/gif_archive/giflib-5.1.4/lib/gif_err.c:10:29: fatal error: gif_lib_private.h: No such file or directory
 #include "gif_lib_private.h"
                             ^
compilation terminated.
Target //tensorflow/examples/android:tensorflow_demo failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 6.687s, Critical Path: 3.33s

And this is my SDK entry for the WORKSPACE file:

android_sdk_repository(
    name = "androidsdk",
    api_level = 24,
    build_tools_version = "24.0.0",
    # Replace with path to Android SDK on your system
    path = "/home/me/Android/Sdk",
)
@andrewharp
Member

Now you've run into an outstanding TF issue :)
#3374

I have a fix incoming, until then just run ./configure for a simple workaround.

@cardshuffle

Thanks for all your help! ./configure worked and the Bazel build was successful. One final question: is there a way to open up a project built with Bazel in Android Studio? I find it easier to view and edit code that way.

@andrewharp
Member

glad you got it working!

Android Studio should be able to let you edit the Android/Java portion of the demo, and maybe the native code too. See http://stackoverflow.com/questions/27570516/how-to-open-an-existing-project-in-android-studio

However, you're probably better off using bazel directly to actually build it for deployment.

@andrewharp andrewharp closed this Jul 19, 2016
@swarathesh

this is a noob question but can i know how to find the location of bazel in my system

@andrewharp
Member

@swarathesh try which bazel

@swarathesh

while ./configure im getting this error Can't find swig. Ensure swig is in $PATH or set $SWIG_PATH.
but i have already installed brew install swig , what to do now @andrewharp

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