Search code examples
tensorflowbazel

Why build bazel everytime we need to run something in TensorFlow?


I've install TensorFlow from sources via bazel build. Everything works fine as expected. But when I'm going through tutorials here https://github.com/tensorflow/models/tree/master/research/slim in readme, it's mentioned to bazel build for each script and I assume bazel is building a lot of sources which it has previouxly built.

Is there a script to build all TensorFlow sources?


Solution

  • it's mentioned to bazel build for each script and I assume bazel is building a lot of sources which it has previouxly built.

    Bazel caches build outputs from previous builds, and only builds what's not yet available, or what may have changed since the last build.

    If you bazel build //foo:a, then, without changing anything in the source tree, you build bazel build //bar:b, then whatever //foo:a and //bar:b both depend on, Bazel will not build again in the second build.

    Does that answer your question?

    Is there a script to build all TensorFlow sources?

    You can tell Bazel to build everything under a given path, e.g. bazel build //foo/bar/..., to build everything in //foo/bar and in all of its subpackages. In this case, you'd want to build everything in the workspace, so you'd run:

    bazel build //...