安装过程分为六步:
1. python安装(Anaconda)
2. python IDE安装(Pytharm)(可跳过)
3. cuda安装(GPU版TensorFlow的支持模块,显卡不是英伟达的可忽略)
4.TensorFlow安装
5.TFlearn安装
6.TensorBoard安装
安装之前建议先上TensorFlow看看各个模块的版本要求,免得走弯路:https://www.tensorflow.org/install/install_windows
可见CUDA的版本要求是8.0,cuDNN版本是6或者6.1。显卡的计算能力要求要高于3.0,可在以下网页中查询自己显卡的计算能力:https://developer.nvidia.com/cuda-gpus
========================1、Python安装========================
Anaconda是集成了很多包的python解释器,例如sklearn, jupyter, scipy等,相比于直接安装python官网上的解释器能节省很多功夫。直接百度Anaconda,进入Anaconda的的官网进行下载https://www.anaconda.com/download/。注意下载Python3的版本,按安装提示进行安装即可。不用在乎python版本。python 3.6也可以安装TensorFlow
安装之后需要把Anaconda添加到系统的环境变量当中。具体步骤为:右击"我的电脑"-->属性-->高级系统设置-->环境变量-->找到Path这个变量并点击编辑-->把Anaconda的安装目录、Script目录、Library\bin目录添加到路径。例如我把Anaconda安装在D:/Apps/Anaconda/,那我要添加的路径为:
D:\Apps\Anaconda;
D:\Apps\Anaconda\Scripts;
D:\Apps\Anaconda\Library\bin
完成此步骤之后,进入命令行,输入python,就可以看到Anaconda已经成功安装
========================2、Python IDE安装========================
百度Pytharm,进入其官网进行下载http://www.jetbrains.com/pycharm/download/#section=windows。记得下载community版本,因为这个版本免费。下载完之后按提示安装即可。
========================3、Cuda安装========================
Tensorflow分为GPU版和CPU版,GPU版要比CPU版快个几十倍,所以推荐安装GPU版。安装GPU版之前首先要进行cuda安装。
首先进入英伟达的官网下载CUDA:https://developer.nvidia.com/cuda-downloads,选择对应的版本即可下载:
下载完成之后按步骤安装即可。最好以管理员身份运行,不然可能会安装失败。记得选对版本,选cuda 8。不然又要费工夫下载一番
安装完同样要把cuda添加到环境变量当中,要添加的路径为:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0。默认情况下这个路径已经被添加了。
此外还需要下载cuDNN,进入英伟达官网进行下载https://developer.nvidia.com/cudnn。记得下载合适的版本:cuDNN v6.0 (April 27, 2017), for CUDA 8.0。下载下来的是一个压缩包。下载之前需要进行简单的注册。下载之后进行解压,把解压之后的目录也添加到环境变量,例如我解压到了D:/Apps/cuda,那我要添加的路径为:
D:\Apps\cuda\bin
D:\Apps\cuda\include
D:\Apps\cuda\lib\x64
安全起见,在环境变量里面新建一个CUDA_PATH变量。把这3个路径添加进去。
========================4、TensorFlow’安装========================
在命令行中输入以下命令:
(1) 创建一个名为tensorflow的conda环境
conda create -n tensorflow python=3.5
(2) 激活这个conda环境
activate tensorflow
(3) 在conda环境中安装GPU版本的TensorFlow:(如果想安装CPU版本,则只需要把"-gpu"去掉)
pip install --ignore-installed --upgrade tensorflow-gpu
但也有可能出现以下错误:
错误1:
Traceback (most recent call last):
File "D:\Program Files\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "D:\Program Files\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in create_module
File "", line 222, in _call_with_frames_removed
ImportError: DLL load failed: 找不到指定的模块。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Program Files\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Program Files\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Program Files\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "D:\Program Files\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
错误2:
Traceback (most recent call last):
File "C:\Users\toy\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\toy\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in create_module
File "", line 222, in _call_with_frames_removed
ImportError: DLL load failed: 找不到指定的模块。
During handling of the above exception, another exception occurred:
pip install tensorflow_gpu-1.0.0-cp35-cp35m-win_amd64.whl
安装完毕之后,像前面所说的一样import tensorflow就能看到成功的页面了。
========================5、Tflearn安装========================
方法1:
pip install tflearn
这么简单的方法按剧情发展通常是不可行的,如果失败了可参考方法2
方法2:
去Git官网下载Git并进行安装:https://git-scm.com/downloads
在命令行输入命令安装tflearn:
pip install git+https://github.com/tflearn/tflearn.git
========================6、TensorBoard安装========================
通常是已经安装好了的,如果没安装,则通过以下命令安装:
pip install tensorboard
安装完成后,可在命令行输入以下命令以测试是否安装成功:
tensorboard --logdir=D:/
关于TensorBoard的简单使用方法可参考我的博文:http://blog.csdn.net/hwj_wayne/article/details/78224599