在Win10上使用Anaconda搭建TensorFlow開發環境
阿新 • • 發佈:2018-11-26
以下內容原本是作為畢業設計的一部分的,因此絕對認真和詳細,由於內容過多所以被刪減了,就當福利送給大家了。
2.2 在Windows 10上搭建TensorFlow開發環境
2.2.1 安裝Anaconda5.0.1
在Windows下的安裝十分簡單,不需要很複雜的步驟。
https://www.anaconda.com/download/#windows
在Anaconda官網上下載相應版本的安裝包,這篇論文選擇的是”64-bit Graphical(515MB)”。
下載完成後直接執行。
選擇可以使用Anaconda的使用者,這裡選擇了Just Me,即當前登入的使用者。
選擇安裝路徑,這裡選擇了預設安裝路徑,你也可以選擇其他路徑。
第一個選項建議勾選,如果你不是第一次安裝Anaconda,記得將之前的環境變數刪除。
第二個選項預設勾選,如果你的電腦上安裝有官方版的Python包或者其他發行版的包,將會被Anaconda覆蓋掉。
安裝成功,Window PowerShell或者CMD裡輸入python,會看到如下結果:
2.2.1 安裝TensorFlow
在開始選單中找到Anaconda Prompt並開啟:
#建立一個虛擬環境
(C:\Users\hongze\AppData\Local\Continuum\anaconda3) C:\Users\hongze>conda create -n tensorflow python=3.6
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment C:\Users\hongze\AppData\Local\Continuum\anaconda3\envs\tensorflow:
The following NEW packages will be INSTALLED:
certifi: 2017.11.5-py36hb8ac631_0
pip: 9.0 .1-py36h226ae91_4
python: 3.6.4-h6538335_0
setuptools: 38.4.0-py36_0
vc: 14-h0510ff6_3
vs2015_runtime: 14.0.25123-3
wheel: 0.30.0-py36h6c3ec14_1
wincertstore: 0.2-py36h7fe50ca_0
Proceed ([y]/n)? y
vs2015_runtime 100% |###############################| Time: 0:00:02 961.77 kB/s
vc-14-h0510ff6 100% |###############################| Time: 0:00:00 597.58 kB/s
python-3.6.4-h 100% |###############################| Time: 0:00:05 4.13 MB/s
certifi-2017.1 100% |###############################| Time: 0:00:00 6.32 MB/s
setuptools-38. 100% |###############################| Time: 0:00:00 8.99 MB/s
wheel-0.30.0-p 100% |###############################| Time: 0:00:00 4.69 MB/s
pip-9.0.1-py36 100% |###############################| Time: 0:00:00 7.68 MB/s
#
# To activate this environment, use:
# > activate tensorflow
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#
#啟用虛擬環境
(C:\Users\hongze\AppData\Local\Continuum\anaconda3) C:\Users\hongze>activate tensorflow
#安裝tensorflow
(tensorflow) C:\Users\hongze>pip install tensorflow
Collecting tensorflow
Downloading tensorflow-1.4.0-cp36-cp36m-win_amd64.whl (28.3MB)
100% |████████████████████████████████| 28.3MB 632kB/s
Collecting tensorflow-tensorboard<0.5.0,>=0.4.0rc1 (from tensorflow)
Downloading tensorflow_tensorboard-0.4.0-py3-none-any.whl (1.7MB)
100% |████████████████████████████████| 1.7MB 1.8MB/s
Collecting six>=1.10.0 (from tensorflow)
Downloading six-1.11.0-py2.py3-none-any.whl
Collecting enum34>=1.1.6 (from tensorflow)
Downloading enum34-1.1.6-py3-none-any.whl
Requirement already satisfied: wheel>=0.26 in c:\users\hongze\appdata\local\continuum\anaconda3\envs\tensorflow\lib\site-packages (from tensorflow)
Collecting protobuf>=3.3.0 (from tensorflow)
Downloading protobuf-3.5.1-py2.py3-none-any.whl (388kB)
100% |████████████████████████████████| 389kB 1.4MB/s
Collecting numpy>=1.12.1 (from tensorflow)
Downloading numpy-1.14.0-cp36-none-win_amd64.whl (13.4MB)
100% |████████████████████████████████| 13.4MB 1.2MB/s
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Downloading Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
100% |████████████████████████████████| 327kB 1.9MB/s
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Downloading bleach-1.5.0-py2.py3-none-any.whl
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Downloading Markdown-2.6.11-py2.py3-none-any.whl (78kB)
100% |████████████████████████████████| 81kB 1.5MB/s
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.5.0,>=0.4.0rc1->tensorflow)
Downloading html5lib-0.9999999.tar.gz (889kB)
100% |████████████████████████████████| 890kB 2.0MB/s
Requirement already satisfied: setuptools in c:\users\hongze\appdata\local\continuum\anaconda3\envs\tensorflow\lib\site-packages (from protobuf>=3.3.0->tensorflow)
Building wheels for collected packages: html5lib
Running setup.py bdist_wheel for html5lib ... done
Stored in directory: C:\Users\hongze\AppData\Local\pip\Cache\wheels\6f\85\6c\56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
Successfully built html5lib
Installing collected packages: werkzeug, six, html5lib, bleach, protobuf, markdown, numpy, tensorflow-tensorboard, enum34, tensorflow
Successfully installed bleach-1.5.0 enum34-1.1.6 html5lib-0.9999999 markdown-2.6.11 numpy-1.14.0 protobuf-3.5.1 six-1.11.0 tensorflow-1.4.0 tensorflow-tensorboard-0.4.0 werkzeug-0.14.1
(tensorflow) C:\Users\hongze>python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 15 2018, 18:58:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hw = tf.consatant("Hello World")
>>> with tf.Session() as sess:
... sess.run(hw)
...
2018-01-18 19:04:19.733504: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
b'Hello World'
>>>
安裝成功,Warning表示tensorflow的二進位制檔案不會用AVX AVX2被編譯,因為你的CPU不支援這些指令, 因為之後的實現是在Jupyter上做的,所以這個可以忽略。