Build of Tensorflow 2.0 from source fails on Windows "Could not find bazel-bin"

Viewed 842

I'm trying to build Tensorflow 2.0 on Windows to make use of AVX2 support, as the default package from "pip install tensorflow" does not include AVX2 support. I'm following the guide here: https://www.tensorflow.org/install/source_windows

After a lot of failed builds, I was finally successful in building after setting the environment variables to Visual Studio 2017. The final command, ran from c:\tmp\tensorflow (which took 9 hours to complete) was:

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package --define=no_tensorflow_py_deps=true

The next step in the instructions "Build the package" says to run

bazel-bin\tensorflow\tools\pip_package\build_pip_package C:/tmp/tensorflow_pkg

If I do that directly (from c:\tmp\tensorflow), I get the error "The system cannot find the path specified.".

I then looked at the final messages from the build:

C:/users/john.doe/_bazel_john.doe/3ttaaxce/execroot/org_tensorflow/bazel-out/x64_windows-opt/bin/tensorflow/tools/pip_package/build_pip_package.exe

INFO: Elapsed time: 32810.307s, Critical Path: 25586.71s

INFO: 8885 processes: 8885 local.

INFO: Build completed successfully, 11312 total actions

From here it looks like build_pip_package.exe is in a different location, so I ran

C:/users/john.doe/_bazel_john.doe/3ttaaxce/execroot/org_tensorflow/bazel-out/x64_windows-opt/bin/tensorflow/tools/pip_package/build_pip_package C:/tmp/tensorflow_pkg

but this resulted in the error:

Fri Oct 11 08:30:40 PDT 2019 : === Preparing sources in dir: /tmp/tmp.B207TraE5w

Could not find bazel-bin. Did you run from the root of the build tree?

Does anyone know what could be wrong?

2 Answers

I solved the problem by re-compiling from source to a new directory c:\tmp2\tensorflow. This time build_pip_package.exe was in the correct location and I was able to successfully build the pip package and install.

Bazel creates a link from bazel-bin to the output directory. This behavior is governed by the --symlink_prefix option. Try running bazel with --announce_rc and see if that option is set somewhere - it may be creating a link with a different name, or not creating one at all.

Also, whatever program in tensorflow assumes the output will be in bazel-bin is mistaken. For node projects we recommend --symlink_prefix=dist/ so the outputs go in dist/bin in your project.

Related