window10 TensorFlow-1.4 安裝
阿新 • • 發佈:2018-11-14
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,>=0.4.0rc1 (from tensorflow-gpu==1.4.0)
Using cached tensorflow_tensorboard-0.4.0-py3-none-any.whl
Collecting six>=1.10.0 (from tensorflow-gpu==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>=3.3.0->tensorflow-gpu==1.4.0)
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow-gpu==1.4.0)
Using cached bleach-1.5.0-py2.py3-none-any.whl
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow-gpu==1.4.0)
Using cached Markdown-2.6.11-py2.py3-none-any.whl
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow-gpu==1.4.0)
Using cached html5lib-0.9999999.tar.gz
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow-gpu==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. (1)安裝CUDA 參考網站:http://blog.sina.com.cn/s/blog_14935c5880102wu86.html
下載並按照CUDA:進入此網站(https://developer.nvidia.com/cuda-downloads),點選Windows
(2)安裝cudnn 參考網站:http://blog.csdn.net/sb19931201/article/details/53648615
cuDNN下載網站(https://developer.nvidia.com/rdp/form/cudnn-download-survey),
(3)安裝提示:
下載這個安裝包需要註冊並且填一堆問卷,下下來以後把相關包不用安裝,直接拷到cuda路徑對應的資料夾下面就行;
將這三個資料夾下的檔案拷到CUDA對應的資料夾下面即可
cuda安裝完成後預設的環境變數配置不對,CUDA_PATH是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0,
但是這樣不能直接訪問到bin和lib\x64下的程式包,在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. 測試
1、進入cmd啟用python35環境,鍵入python進入python shell;
2、輸入import tensorflow as tf匯入tensorflow庫,無報錯即成功安裝TensorFlow;
3、鍵入程式碼
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
>>> hello=tf.constant('hello,tensorflow!')
>>> sess=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__
'1.4.0'
>>> a=tf.random_normal((100,100))
>>> b=tf.random_normal((100,500))
>>> c=tf.matmul(a,b)
>>> sess = 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+01, -2.83940554e+00, 3.25224590e+00, ...,
1.48687639e+01, 1.14226675e+01, -2.92734909e+01],
[-1.78896534e+00, 1.63350086e+01, -2.12260437e+01, ...,
-9.29720116e+00, 1.34245167e+01, 6.11474180e+00],
[-1.08380480e+01, -1.27219784e+00, 7.25827408e+00, ...,
-9.24288750e+00, 7.42250681e+00, 8.72167200e-02],
...,
[ 1.50586033e+00, -1.09648788e-02, -6.79777718e+00, ...,
4.91322136e+00, -7.05123472e+00, -3.51647973e+00],
[-5.51862574e+00, 4.30281878e+00, -5.66631556e+00, ...,
-4.48143864e+00, 9.17361164e+00, -6.72823429e+00],
[ 1.17639284e+01, -1.05234756e+01, -1.81000245e+00, ...,
3.35602999e+00, 7.88399172e+00, 9.59712029e+00]], dtype=float32)