tensorflow: Build errors for libtensorflow_inference.so

I am trying to build libtensorflow_inference.so, in order to run a TF model in an Android app. I found the following command in issue #6166, however the command is failing. I reported an earlier error message in that issue, but now the error message has changed and it fails completely.
It is worth noting that I am able to compile the Inception demo app with no trouble (from inside Android Studio), so I think the full tool chain is functional. I added the verbose option to try to troubleshoot the issue (not that it helped):

$ bazel build //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a --verbose_failures I am running on MacOS (10.12.1) with TF0.12 (SHA=46b7b6). Installed version of CUDA and cuDNN: None Bazel Verion:

Build label: 0.4.2-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 8 03:17:26 2016 (1481167046)
Build timestamp: 1481167046
Build timestamp as int: 1481167046

Here is the error message:

WARNING: /Users/kevin/tensorflow/tensorflow/core/BUILD:779: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: /Users/kevin/tensorflow/tensorflow/core/BUILD:779: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: /Users/kevin/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops.h' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /Users/kevin/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops_common.h' directly. You should either move the file to this package or depend on an appropriate rule there.
<snip>
WARNING: /Users/kevin/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:tensor_bundle.cc' directly. You should either move the file to this package or depend on an appropriate rule there.
WARNING: /Users/kevin/tensorflow/tensorflow/core/BUILD:779:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:tensor_bundle.h' directly. You should either move the file to this package or depend on an appropriate rule there.
INFO: Found 1 target...
ERROR: /Users/kevin/tensorflow/tensorflow/core/BUILD:163:1: C++ compilation of rule '//tensorflow/core:protos_all_cc' failed: sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_kevin/a09094529daf7e22afa1fbacb9484a3a/bazel-sandbox/4c850042-6906-474b-9554-e958a1aadaeb-3/execroot/tensorflow && \
  exec env - \
    PATH=/Users/kevin/anaconda2/bin:/Users/kevin/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
    TMPDIR=/var/folders/cm/1r6x6rbj7hn_51qvfjzj7nx80000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_kevin/a09094529daf7e22afa1fbacb9484a3a/bazel-sandbox/4c850042-6906-474b-9554-e958a1aadaeb-3/sandbox.sb /bin/false -MD -MF bazel-out/stub_armeabi-v7a-fastbuild/bin/tensorflow/core/_objs/protos_all_cc/tensorflow/core/framework/device_attributes.pb.pic.d '-frandom-seed=bazel-out/stub_armeabi-v7a-fastbuild/bin/tensorflow/core/_objs/protos_all_cc/tensorflow/core/framework/device_attributes.pb.pic.o' -fPIC -iquote . -iquote bazel-out/stub_armeabi-v7a-fastbuild/genfiles -iquote external/protobuf -iquote bazel-out/stub_armeabi-v7a-fastbuild/genfiles/external/protobuf -iquote external/bazel_tools -iquote bazel-out/stub_armeabi-v7a-fastbuild/genfiles/external/bazel_tools -isystem external/protobuf/src -isystem bazel-out/stub_armeabi-v7a-fastbuild/genfiles/external/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-sign-compare -c bazel-out/stub_armeabi-v7a-fastbuild/genfiles/tensorflow/core/framework/device_attributes.pb.cc -o bazel-out/stub_armeabi-v7a-fastbuild/bin/tensorflow/core/_objs/protos_all_cc/tensorflow/core/framework/device_attributes.pb.pic.o).
sandbox-exec: /bin/false: No such file or directory
Target //tensorflow/contrib/android:libtensorflow_inference.so failed to build
INFO: Elapsed time: 44.632s, Critical Path: 2.86s

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

The Tensorflow TF Detect for android example draws boxes around humans seen by the camera, however I would like to train a model to detect things other than humans.

@kevinashaw Yes, this is the library you want, along with the corresponding Java src that //tensorflow/contrib/android:android_tensorflow_inference_java will place in a Jar file for you.

On OSX false may be found in /usr/bin/, not /bin, though I’m not sure if that’s the root cause of the problem. Can you try bazel clean and then rebuild with --sandbox_debug enabled? That may provide a more informative error.

Hi,

I am having the same issue…The bazel build

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

runs for a very long time and throws up error 😦 bazel clean doesnt help…

Can some one please help… screen shot 2017-05-07 at 9 06 34 pm screen shot 2017-05-08 at 10 49 40 am

Closing; please update if there are any remaining issues.

It’s also worth mentioning that we are planning on providing an AAR solution soon that should make integrating TF into Android apps in Android Studio much simpler if you do not need to modify native C/C++ code.