Search code examples
c++tensorflowbazel

Tensorflow C++ API example line ending?


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?


Solution

  • 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.