Win10平台从源码构建支持GPU的tensorflow

Win10平台从源码构建支持GPU的tensorflow

2019-05-16 14:23:31
上海

由于预编译的TF版本不支持 Compute Capability 为 3.0 的GPU,至少需要是 3.5,于是从源码开始构建。

失败的尝试

  • anaconda python 3.7
  • msys2-x86_64-20180531
  • bazel-0.25.2-windows-x86_64, bazel-0.24.1-windows-x86_64 和 bazel-0.15.0-windows-x86_64
  • Microsoft Visual C++ 2015 Redistributable 更新 3
  • Microsoft 生成工具 2015 更新 3
  • GPU: NVIDIA Quadro K1100M(Compute Capability: 3.0)
  • NVIDIA GPU Driver 416.78
  • cuda 10.0
  • cudnn 7.5
  • tensorflow-1.13 和 tensorflow-1.12

遵循官网的步骤,尝试了上述的组合,均出现了诸如找不到包的致命问题。

放弃。

成功的尝试

  • python 3.6
  • msys2-x86_64-20180531
  • bazel-0.15.0-windows-x86_64
  • Microsoft Visual C++ 2015 Redistributable 更新 3
  • Microsoft 生成工具 2015 更新 3
  • GPU: NVIDIA Quadro K1100M(Compute Capability: 3.0)
  • NVIDIA GPU Driver 416.78
  • cuda 9.2
  • cudnn-9.2-windows10-x64-v7.5.1.10
  • tensorflow-1.12

较新的版本没有成功,于是稍微回退一下。参考官网上的经过测试的编译配置,重新安装了原生的 python 3.6,使用 TF 1.12。
依旧按照官网的步骤。

编译时间比较久,一个多小时,好歹成功了,但是 Warning 很多:)

INFO: Elapsed time: 5194.237s, Critical Path: 784.67s
INFO: 4504 processes: 4504 local.
INFO: Build completed successfully, 6049 total actions

由于 Bazel 的版本比较老,必须借助 MSYS Shell 来编译软件包。参照官网步骤,停用 MSYS 的路径转换,并设置了必要的 PATH 后,在 MSYS Shell 中切换到项目根目录并输入:

$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /d/tmp/tensorflow_pkg
2019年05月17日 9:51:12 : === Preparing sources in dir: /tmp/tmp.fP9a10VeyS
Unzipping simple_console_for_windows.zip to create runfiles tree...
Unzip finished.
/d/Desktop/tensorflow-1.12.2 /d/Desktop/tensorflow-1.12.2
/d/Desktop/tensorflow-1.12.2
2019年05月17日 10:04:44 : === Building wheel
2019年05月17日 10:06:50 : === Output wheel file is in: /d/tmp/tensorflow_pkg

软件包就在 D:\tmp\tensorflow_pkg 目录下了。
安装即可。

在 GitHub 上查看本页