使用SSE4.2和AVX编译TensorFlow失败并带有bazel

时间:2018-08-05 19:37:58

标签: tensorflow sse bazel avx msys

我已经安装了Tensorflow Bazel和MSYS,并尝试使用Win下的以下命令编译Tensorflow以支持 CPU扩展,例如SSE4.1,SSE4.2,AVX,AVX2,FMA 10命令提示符:

  bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=- 
  mfpmath=both --copt=-msse4.2 --config=cuda -k 
 //tensorflow/tools/pip_package:build_pip_package

但是失败,并显示以下错误:

C:\WINDOWS\system32>bazel build -c opt --copt=-mavx --copt=-mavx2 
--copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=cuda - 
 k //tensorflow/tools/pip_package:build_pip_package
 Bazel on Windows requires bash.exe and other Unix tools, but we 
could not find them.
If you do not have them installed, the easiest is to install 
 MSYS2 from
 http://repo.msys2.org/distrib/msys2-x86_64-latest.exe
 or git-on-Windows from
 https://git-scm.com/download/win

If you already have bash.exe installed but Bazel cannot find 
it,
set BAZEL_SH environment variable to its location:
set BAZEL_SH=c:\path\to\bash.exe
[bazel INFO src/main/cpp/blaze_util_windows.cc:1231] Cannot 
 open 
 HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Git_is1
 [bazel ERROR src/main/cpp/blaze_util_windows.cc:1303] bash.exe 
 not found on PATH
 [bazel INFO src/main/cpp/blaze_util_windows.cc:1328] BAZEL_SH 
 detection took 0 msec, found

MSYS正常运行,如下所示:

ippok@DESKTOP-4QMUDH4 MSYS ~
$

1 个答案:

答案 0 :(得分:1)

错误消息告诉您该怎么做:将BAZEL_SH envvar设置为bash.exe的路径。

要为当前cmd.exe会话设置它,请使用:

set BAZEL_SH=c:\msys64\usr\bin\bash.exe

要为所有未来 cmd.exe会话(不是该会话)设置它:

setx BAZEL_SH "c:\msys64\usr\bin\bash.exe"

如果将MSYS安装在其他位置,请相应地更改这些命令。