Search code examples
pythontensorflowbazel

Install specific version of Bazel with Bazelisk


I am trying to use Bazel to rebuild Tensorflow with compiler flags, but have been getting errors.

In the documentation explaining how to build Tensorflow from the source, they say that Bazelisk will download the correct version for Tensorflow... but when I was getting the errors, I decided to check the Bazel version and it said 4.2.2 (which is the latest version). The tested builds the Bazel version is only 3.7.2 for 2.7 version of Tensorflow (which is what I am using)...

Is there a way to use Bazelisk to install version 3.7.2? Or do I have to manually download Bazel and add it to the path?

  • If so, how do I do it? The way I installed it before was just downloading and running the .exe file from the website... and there wasn't any opportunity to enter a version for Bazel...
  • If not, how do I uninstall Bazelisk? I tried looking for a way to uninstall, but couldn't find anything...

Solution

  • Bazelisk will look in the WORKSPACE root for a file named .bazelversion (see here). This file is supposed to contain the Bazel version number you want to use.

    There are also other options to tell Bazelisk which version to use: How does Bazelisk know which Bazel version to run?

    To use for instance Bazel 0.26.1 you can Bazelisk this way:

    $ USE_BAZEL_VERSION=0.26.1 bazelisk version