1. 第一步首先需要去下载一个Python。用管理员身份打开cmd窗口,输入命令conda create --name python35 python=3.5,等待安装完成即可;
注意:必须为3.5版本激活:
activate python35
释放
deactivate
#To activate this environment, use:
# > activate python35
#
# To deactivate an active environment, use:
# > deactivate
2. 各版本TensorFlow下载地址:https://pypi.python.org/pypi/tensorflow-gpu/1.4.0(python35) C:\Users\Administrator>pip install tensorflow_gpu-1.4.0-cp35-cp35m-win_amd64.whl
Processing c:\users\administrator\tensorflow_gpu-1.4.0-cp35-cp35m-win_amd64.whl
Collecting enum34>=1.1.6 (from tensorflow-gpu==1.4.0)
Using cached enum34-1.1.6-py3-none-any.whl
Collecting protobuf>=3.3.0 (from tensorflow-gpu==1.4.0)
Downloading protobuf-3.5.2-cp35-cp35m-win_amd64.whl (958kB)
100% |████████████████████████████████| 962kB 46kB/s
Collecting numpy>=1.12.1 (from tensorflow-gpu==1.4.0)
Downloading numpy-1.14.2-cp35-none-win_amd64.whl (13.4MB)
100% |████████████████████████████████| 13.4MB 1.0MB/s
Requirement already satisfied: wheel>=0.26 in c:\users\administrator\anaconda3\envs\python35\lib\site-packages (from tensorflow-gpu==1.4.0)
Collecting tensorflow-tensorboard<0.5.0,>&#61;0.4.0rc1 (from tensorflow-gpu&#61;&#61;1.4.0)
Using cached tensorflow_tensorboard-0.4.0-py3-none-any.whl
Collecting six>&#61;1.10.0 (from tensorflow-gpu&#61;&#61;1.4.0)
Downloading six-1.11.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in c:\users\administrator\anaconda3\envs\python35\lib\site-packages (from protobuf>&#61;3.3.0->tensorflow-gpu&#61;&#61;1.4.0)
Collecting bleach&#61;&#61;1.5.0 (from tensorflow-tensorboard<0.5.0,>&#61;0.4.0rc1->tensorflow-gpu&#61;&#61;1.4.0)
Using cached bleach-1.5.0-py2.py3-none-any.whl
Collecting markdown>&#61;2.6.8 (from tensorflow-tensorboard<0.5.0,>&#61;0.4.0rc1->tensorflow-gpu&#61;&#61;1.4.0)
Using cached Markdown-2.6.11-py2.py3-none-any.whl
Collecting html5lib&#61;&#61;0.9999999 (from tensorflow-tensorboard<0.5.0,>&#61;0.4.0rc1->tensorflow-gpu&#61;&#61;1.4.0)
Using cached html5lib-0.9999999.tar.gz
Collecting werkzeug>&#61;0.11.10 (from tensorflow-tensorboard<0.5.0,>&#61;0.4.0rc1->tensorflow-gpu&#61;&#61;1.4.0)
Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
100% |████████████████████████████████| 327kB 1.7MB/s
Building wheels for collected packages: html5lib
Running setup.py bdist_wheel for html5lib ... done
Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\6f\85\6c\56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
Successfully built html5lib
Installing collected packages: enum34, six, protobuf, numpy, html5lib, bleach, markdown, werkzeug, tensorflow-tensorboard, tensorflow-gpu
Successfully installed bleach-1.5.0 enum34-1.1.6 html5lib-0.9999999 markdown-2.6.11 numpy-1.14.2 protobuf-3.5.2 six-1.11.0 tensorflow-gpu-1.4.0 tensorflow-tensorboard-0.4.0 werkzeug-0.14.1
3. &#xff08;1&#xff09;安装CUDA 参考网站&#xff1a;http://blog.sina.com.cn/s/blog_14935c5880102wu86.html下载并按照CUDA&#xff1a;进入此网站(https://developer.nvidia.com/cuda-downloads)&#xff0c;点击Windows
&#xff08;2&#xff09;安装cudnn 参考网站&#xff1a;http://blog.csdn.net/sb19931201/article/details/53648615
cuDNN下载网站(https://developer.nvidia.com/rdp/form/cudnn-download-survey)&#xff0c;
&#xff08;3&#xff09;安装提示&#xff1a;
下载这个安装包需要注册并且填一堆问卷&#xff0c;下下来以后把相关包不用安装&#xff0c;直接拷到cuda路径对应的文件夹下面就行;
将这三个文件夹下的文件拷到CUDA对应的文件夹下面即可cuda安装完成后默认的环境变量配置不对&#xff0c;CUDA_PATH是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0,
但是这样不能直接访问到bin和lib\x64下的程序包&#xff0c;在path中加上这两个路径即可。
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\lib\x64
(4)
下载并安装Anaconda&#xff1a;进入下载网站(https://www.continuum.io/downloads)&#xff0c;点击Windows图标4. 测试1、进入cmd激活python35环境&#xff0c;键入python进入python shell&#xff1b;
2、输入import tensorflow as tf导入tensorflow库&#xff0c;无报错即成功安装TensorFlow&#xff1b;
3、键入代码
hello &#61; tf.constant(&#39;Hello, TensorFlow!&#39;)
sess &#61; tf.Session()
>>> hello&#61;tf.constant(&#39;hello,tensorflow!&#39;)
>>> sess&#61;tf.Session()
2018-03-16 11:47:17.431306: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2018-03-16 11:47:18.130259: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.7085
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 5.01GiB
2018-03-16 11:47:18.130433: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
>>>
>>> tf.__version__
&#39;1.4.0&#39;
>>> a&#61;tf.random_normal((100,100))
>>> b&#61;tf.random_normal((100,500))
>>> c&#61;tf.matmul(a,b)
>>> sess &#61; tf.InteractiveSession()
2018-03-16 11:52:38.934649: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
>>> sess.run(c)
array([[ 2.38107853e&#43;01, -2.83940554e&#43;00, 3.25224590e&#43;00, ...,
1.48687639e&#43;01, 1.14226675e&#43;01, -2.92734909e&#43;01],
[-1.78896534e&#43;00, 1.63350086e&#43;01, -2.12260437e&#43;01, ...,
-9.29720116e&#43;00, 1.34245167e&#43;01, 6.11474180e&#43;00],
[-1.08380480e&#43;01, -1.27219784e&#43;00, 7.25827408e&#43;00, ...,
-9.24288750e&#43;00, 7.42250681e&#43;00, 8.72167200e-02],
...,
[ 1.50586033e&#43;00, -1.09648788e-02, -6.79777718e&#43;00, ...,
4.91322136e&#43;00, -7.05123472e&#43;00, -3.51647973e&#43;00],
[-5.51862574e&#43;00, 4.30281878e&#43;00, -5.66631556e&#43;00, ...,
-4.48143864e&#43;00, 9.17361164e&#43;00, -6.72823429e&#43;00],
[ 1.17639284e&#43;01, -1.05234756e&#43;01, -1.81000245e&#43;00, ...,
3.35602999e&#43;00, 7.88399172e&#43;00, 9.59712029e&#43;00]], dtype&#61;float32)