官网上提供了tensorflow的ubutun和window下的安装,这里先介绍windows
https://tensorflow.google.cn/install/source_windows
1、install python and package
Install a Python 3.5.x or Python 3.6.x 64-bit release for Windows(我选择的是3.6)
pip install package
pip3 install six numpy wheel
pip3 install keras_applications==1.0.6 --no-deps
pip3 install keras_preprocessing==1.0.5 --no-deps
2、install bazel
Download Bazel for Windows from GitHub.:https://github.com/bazelbuild/bazel/releases
you will get bazel****.exe and better change it to bazel.exe
3、install msys2
Download msys2 for windons:https://www.msys2.org/
run command to set patch:
pacman -S git patch unzip
4、Install Visual C++ Build Tools(我选择的是2017)
Download vs for windons:https://visualstudio.microsoft.com/zh-hans/vs/older-downloads/?rr=https%3A%2F%2Ftensorflow.google.cn%2Finstall%2Fsource_windows
5、Edit environment variables.
- Edit
Path
. Add new entries to the beginning of the list:- The directory of
bazel.exe
. (Example:c:\bazel
). - The
usr\bin
directory of MSYS2. (Example:c:\msys64\usr\bin
). - If you will build Python code: the directory of
python.exe
. (Example:c:\python3
).
- The directory of
- Add
BAZEL_SH
. Its value must be the path to MSYS2 Bash. Example:c:\msys64\usr\bin\bash.exe
- Add
JAVA_HOME
(if you will build Java code). Its value must be the directory where you installed the Java JDK 8, for exampleC:\Program Files\Java\jdk1.8.0_152
6、get tensorflow code and config
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout branch_name # r1.9, r1.10, etc. python ./configure.py
7、bazel build freeze_graph and toco
bazel build tensorflow/python/tools:freeze_graph (it is a long time)
bazel build //tensorflow/contrib/lite/toco:toco