在 Windows7 上构建 tensorflow

Building tensorflow on Windows7

我正在尝试在 Windows7 64 位上构建 tensorflow 以加速 CPU 计算(SSE、AVX)。我正在使用 bazel 和 msys64 进行构建和此配置:

(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

之后,我用 bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package 构建了一个脚本,最后得到一个错误:

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

怎么了?也许我应该使用一些其他配置选项?

TensorFlow 使用以下脚本通过 Bazel 在 Windows 上构建和测试: tensorflow/tools/ci_build/windows/cpu/pip/build_tf_windows.sh

设置基本是:

  1. 运行 ./configure

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

对于 Cannot open compiler generated file: '': Invalid argument 错误,您很可能在 Windows 上达到了 260 个字符的路径限制。

请将TMPDIR设置为较短的路径,例如C:/tmp。它将取代 C:/users/denis/appdata/local/temp,并有望缓解长路径问题。