现在网络上大多数是基于Ubuntu等发行版和Python2.7的教程,基于Windows和Python3.6的较少(Windows版TensorFlow只支持Python3.6),故写此文已做笔记。
环境搭建
软件版本
Windows 7 sp1 或者 Windows 10 最新版(其他 Windows 应该类似);
Anaconda,直接官网下载最新版即可,32位,64位注意一下,笔者使用64位;
TensorFlow,1.8.0(落笔时最新版)推荐文档TensorFly,使用Anaconda进行安装;
Vistual Studio Code,微软出品编辑器,轻量级,插件丰富,使用Anaconda进行安装,也可去官网安装。
Jupyter QtConsole,比较好用的console,使用Anaconda进行安装。
软件安装
Anaconda安装
Anaconda安装比较简单,下一步,下一步就行了,可以在安装过程中设置 Anaconda 做为缺省的 Python 3.6。
TensorFlow安装
创建专用环境(推荐)
安装完成之后,点击开始 -> 所有程序 -> anaconda -> Anaconda Navigator;

打开之后,点击右侧Environments,点击create,输入名称(可任意起,建议英文),选择 Python3.6, 点击create;

在环境安装TensorFlow
点击选择你刚创建的环境,我这里叫tensorflow,点击运行按钮,选择Open Terminal;
输入命令
pip install --ignore-installed --upgrade tensorflow
等待安装成功即可。
Vistual Studio Code 和 Jupyter QtConsole 安装(可选)
在 home 中,确保为要开发TensorFlow的环境,我这里为TensorFlow(就是上面创建的环境,以后我们每次开发都会切换到这个环境,以后不再赘述),然后选择需要安装的软件即可。我这里这个环境已经安装,所以这里是启动launch。

环境搭建验证(三选一)
Jupyter QtConsole 验证
启动 Jupyter QtConsole 输入
import tensorflow as tf
tf.__version__
tf.__path__

Terminal 验证
点击选择你刚创建的环境,我这里叫tensorflow,点击运行按钮,选择Open Terminal,输入python命令启动python console,输入上述命令会有同样的效果。
结论
在 Windows 平台,使用 Anaconda 安装 TensorFlow 非常的方便,如果只是学习,不需要 CPU 或者 GPU 指令集优化,可以这样快速安装,如果需要硬件优化则需要自己编译 TensorFlow 并且下载相应软件。
下一篇,我们按照文档编写我们第一个 TensorFlow 程序。
网友评论