轉載請註明出處:http://blog.csdn.net/cxsydjn/article/details/71266969
TensorFlow 是谷歌開發的一款深度學習框架。它是當前最流行的之一,當然最近還有PyTorch。TensorFlow 支持分佈式訓練,包含TensorBoard 支持數據/結果可視化。如果你對深度學習很感興趣的話,它不容錯過。
由於MBP的GPU是Intel Iris Pro,不是NVIDIA系列卡,無奈不能支持CUDA (Compute Unified Device Architecture),(買的時候沒想太多,哭),所以只能安裝CPU-only的TensorFlow。
安裝配置:
Item | Type | Value |
---|---|---|
PC | MBPr | 2015 |
OS | OS X EI Capitan | 10.11.6 |
GPU | Intel Iris Pro | 1536 MB |
CPU | DDR3 | 8G*2 |
Mac的三步安裝過程可以參考 TensorFlow官網 和 TensorFlow Github倉庫。
第一步:安裝pip
pip是一個安裝、管理Python的工具[1]。Mac下利用pip(version 8.1及以上版本)進行安裝TensorFlow很方便。如果已經安裝了Anaconda,那pip已經集成其中了,(Mac下Anaconda配置)。
# Mac OS X
$ sudo easy_install pip
$ sudo easy_install --upgrade six
第二步:設置安裝包URL
CPU-only的TensorFlow安裝包:
# Mac OS X, CPU only, Python 2.7:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.1.0-py2-none-any.whl
# Mac OS X, CPU only, Python 3.4 or 3.5:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.1.0-py3-none-any.whl
第三步:通過pip安裝TensorFlow
# Python 2
$ sudo pip install --upgrade $TF_BINARY_URL
# Python 3
$ sudo pip3 install --upgrade $TF_BINARY_URL
測試樣例
通過官方測試樣例測試是否安裝成功。進入Python環境後輸入以下代碼,當出現”Hello, TensorFlow!”時表明已經安裝成功,可正常使用了。
$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!