Search code examples
tensorflowbazel

Bazel Tensorflow installation from source: Unrecognized option: --host_force_python=py2


I'm trying to install tensorflow from source. When running the configure file I selected all the default parameters, then when trying to run:

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

I get the message:

INFO: Reading options for 'build' from /home/ubuntu/tensorflow/tensorflow/tools/bazel.rc:
  'build' options: --force_python=py2 --host_force_python=py2 --python2_path=/usr/bin/python --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --define PYTHON_BIN_PATH=/usr/bin/python --spawn_strategy=standalone --genrule_strategy=standalone
Unrecognized option: --host_force_python=py2

Then when I try to run the build_pip_package command, it can't findthe build_pip_package command:

build_pip_package: command not found

Although there does exist a build_pip_package file inside bazel-bin/tensorflow/tools/pip_package


Solution

  • It sounds like the Bazel you're using doesn't know about the --host_force_python flag. The flag was added in January, is it possible you're using an old version of Bazel? You can check with bazel version, make sure you're using at least 0.1.4 (optimally you'd be using 0.3.0).

    Alternatively, you could just open up /home/ubuntu/tensorflow/tensorflow/tools/bazel.rc and remove the line build --host_force_python=py2, but I don't know how necessary that line is (so that might cause other problems).