0

I have a problem running the standard C++ API example: https://www.tensorflow.org/api_guides/cc/guide

I created all the files and directories. Bazel then throws an error after being started.

INFO: From Compiling external/snappy/snappy-sinksource.cc [for host]:
cc1plus: warning: command line option '-Wno-implicit-function-declaration' is valid for C/ObjC but not for C++
ERROR: /home/[...]/tensorflow/tensorflow/core/BUILD:1796:1: Executing genrule //tensorflow/core:version_info_gen failed (Exit 127): bash failed: error executing command 
  (cd /home/[...]/.cache/bazel/_bazel_[...]/[...]/org_tensorflow && \
  exec env - \
    LD_LIBRARY_PATH=/opt/ros/lunar/lib \
    PATH=/opt/ros/lunar/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; tensorflow/tools/git/gen_git_source.py --generate external/local_config_git/gen/spec.json external/local_config_git/gen/head external/local_config_git/gen/branch_ref "bazel-out/host/genfiles/tensorflow/core/util/version_info.cc"')
/usr/bin/env: 'python\r': No such file or directory
Target //tensorflow/cc/example:example failed to build
INFO: Elapsed time: 2.329s, Critical Path: 0.57s
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target

My system is running Debian. It looks like there is an issue with the line ending, but I could not really find anything. Shouldn't work the examples under Linux systems by default?

Or did I misconfigure bazel somehow?

Jan B.
  • 77
  • 1
  • 7

2 Answers2

0

After running dos2unix on all files in the tensorflow directory, compilation works. I think this is really weird. Shouldn't tf be supposed to run out of the box in a Unix system? Anyway, refer How can I run dos2unix on an entire directory? to run dos2unix recursively.

Jan B.
  • 77
  • 1
  • 7
0

I got the same error Build failed. Not running target when trying to follow their guide. For me the problem was solved by explicitly compiling Tensorflow with bazel before compiling and running the example.cc file. I.e. :

  • ./configure
  • bazel build //tensorflow:libtensorflow_cc.so
  • bazel run -c opt //tensorflow/cc/example:example
lengerke
  • 1
  • 1