VS2015 bazel0.26.1 tensorflow2.0.0-cpu msys2 python3.6.6
一、搭建环境
1、安装Python3.6.6,并添加到环境变量。
2、安装bazel0.26.1,并添加到环境变量。
3、安装msys2,添加到环境变量后,使用打开cmd,运行命令:pacman -S git patch unzip
4、下载tensorflow2.0.0-cpu源码
二、编译
1、cmd进入tensorflow目录,然后执行python ./configure.py,然后出现各种配置的选择,根据自己实际情况选择即可。
2、编译
Release:
dll: bazel build --config=opt //tensorflow:tensorflow_cc.dll
lib: bazel build --config=opt //tensorflow:tensorflow_cc_dll_import_lib
头文件:bazel build --config=opt //tensorflow:install_headers
然后在你放源码的地方)下的 bazel_bin 中会有相应的 include 文件夹, tensorflow_cc.dll 和 tensorflow_cc.lib 文件, 把它们复制出来放到你的程序里即可。
如果你把编译好的文件都复制出来了, 可以输入 bazel clean 清除不用的文件释放硬盘空间
三、注意问题
1、编译过程中出现rebatch.cc文件报错情况。作以下修改:
Previous:
constexpr std::array<const char*, 6> kBatchDatasetOps = {
kBatchOp, kBatchV2Op, kMapAndBatchOp, kExperimentalMapAndBatchOp,
kPaddedBatchOp, kPaddedBatchV2Op};
Changed:
constexpr std::array<const char*, 6> kBatchDatasetOps = {
"BatchDataset", "BatchDatasetV2", "MapAndBatchDataset", "ExperimentalMapAndBatchDataset",
"PaddedBatchDataset", "PaddedBatchDatasetV2"
};
2、 存储位置修改
3、有些无法下载的包可以手动下载好,部署本地服务器,修改配置文件下载。