Search code examples
python-3.xtensorflowbazel

Building tensorflow on Windows7


I am trying to build tensorflow on Windows7 64-bit in order to speed up CPU computations (SSE, AVX). I am using bazel and msys64 for building and this configuration:

(intel35) c:\Projects\Atari\tensorflow>bash ./configure
You have bazel 0.7.0 installed.
Please specify the location of python. [Default is E:\Programs\Anaconda3\envs\intel35\python.exe]:
Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
Do you wish to build TensorFlow with GDR support? [y/N]: n
Do you wish to build TensorFlow with VERBS support? [y/N]: n
Do you wish to build TensorFlow with CUDA support? [y/N]: n
Do you wish to build TensorFlow with MPI support? [y/N]: n
Please specify optimization flags to use during compilation when bazel option "-
-config=opt" is specified [Default is -march=native]:
Add "--config=mkl" to your bazel command to build with MKL support.
Please note that MKL on MacOS or windows is still not supported.
If you would like to use a local MKL instead of downloading, please set the environment variable "TF_MKL_ROOT" every time before build.
Configuration finished

After that I build a script with bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package and finally get an error:

ERROR: C:/users/denis/appdata/local/temp/_bazel_denis/wkdcwyhr/external/protobuf_archive/BUILD:656:1: C++ compilation of rule '@protobuf_archive//:python/google/protobuf/internal/_api_implementation.so' failed (Exit 1).
C:\users\denis\appdata\local\temp\_bazel_denis\wkdcwyhr\execroot\org_tensorflow\external\protobuf_archive\python\google\protobuf\internal\api_implementation.cc
: fatal error C1083: Cannot open compiler generated file: '': Invalid argument
cl : Command line warning D9002 : ignoring unknown option '-march=native'
cl : Command line warning D9002 : ignoring unknown option '-march=native'
____Building complete.
Target //tensorflow/tools/pip_package:build_pip_package failed to build

What's wrong? Maybe I should use some other configuration options?


Solution

  • TensorFlow uses the following script to build and test on Windows with Bazel: tensorflow/tools/ci_build/windows/cpu/pip/build_tf_windows.sh

    The setups basically are:

    1. Run ./configure

    2. bazel build -c opt --config=monolithic --copt=-w --host_copt=-w --verbose_failures tensorflow/tools/pip_package:build_pip_package

    For Cannot open compiler generated file: '': Invalid argument error, it is very possible that you hit the 260 character path limit on Windows.

    Please set TMPDIR to a shorter path, for example C:/tmp. It will replace C:/users/denis/appdata/local/temp, and hopefully ease the long path issue.