在Windows上编译Tensorflow

参考https://joe-antognini.github.io/machine-learning/build-windows-tf

1.安装cmake 3.6
2.安装swig 3.0.10
3.安装VS2015
4.执行C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat
5.下载Tensorflow
C:\...> git clone https://github.com/tensorflow/tensorflow.git
6.生成cmake 文件
C:\...> cd tensorflow\tensorflow\contrib\cmake
C:\...> mkdir build
C:\...> cd build
C:\...>cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=C:\swigwin-3.0.10\swig.exe -DPYTHON_EXECUTABLE=C:\Users\Administrator\Anaconda3\python.exe -DPYTHON_LIBRARIES=C:\Users\Administrator\Anaconda3\libs\python35.lib -Dtensorflow_BUILD_SHARED_LIB=ON

注意编译过程中有可能会出现下面的错误

'submodule' appears to be a git command, but we were not able to execute it. Maybe git-submodule is broken?

好像VS2015自带的git有问题,这时要将vs2015的git删除,然后用cmake重新生成一下makefile。

上面的-Dtensorflow_BUILD_SHARED_LIB=ON 会让方案生成tensorflow.dll

7.打开Tensorflow.sln ,点build
8.编译过程中有时会遇到unicode的错误,比如re2的测试,把错误的字符串修改一下就可以了