-->

Tensorflow and Bazel c++

2019-08-01 11:09发布

问题:

I'm trying to build tensorflow C++ from sources but no success. I followed different tutorials, but each time, there is a different error.

What I want to do is to create a library so I can use it with Qt. I followed this tutorial because it was exactly what I wanted: https://tuatini.me/building-tensorflow-as-a-standalone-project/ (build on Ubuntu, not on raspberry)

It works fine until I have to use babel. The tutorial says I have to run this command: bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so

but it always fails with the error: ERROR: /home/default/.cache/bazel/_bazel_default/045e1c5e9b482c7b029d706e128fc7e7/external/io_bazel_rules_closure/closure/stylesheets/closure_css_library.bzl:27:13: name 'set' is not defined

I have no idea where I'm supposed to define 'set' (I remove the .cache/bazel folder)

Other tutorials I followed gave me errors such as bazel needs to be > 0.4.3, found 0.13.1 as if it was strings instead of numbers...

Any idea on how to make it work?

回答1:

Do you need to build Tensorflow 1.3.0? There's an old version of TF that can only be built with Bazel 0.5.1, according to the tutorial. You have Bazel 0.13.1, which doesn't support the keyword set in the build scripts. The latest version of TF is buildable with Bazel 0.13.1.

If you need to build 1.3.0, install an older version of Bazel (e.g. 0.5.4) from https://github.com/bazelbuild/bazel/tags?before=0.4.3.

To be exact, this error comes from one of the dependencies of TF, and not TF itself.