Tensorflow安裝手冊

Tensorflow安裝手冊

tony:~ xdwang$ sudo easy_install pip
Password:
Searching for pip
Best match: pip 8.0.2
Adding pip 8.0.2 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /usr/local/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip

tony:~ xdwang$ sudo pip install --upgrade virtualenv
The directory '/Users/xdwang/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/xdwang/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 73kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
tony:~ xdwang$ sudo pip install --upgrade pip
The directory '/Users/xdwang/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/xdwang/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 94kB/s
Installing collected packages: pip
Found existing installation: pip 8.0.2
Uninstalling pip-8.0.2:
Successfully uninstalled pip-8.0.2
Successfully installed pip-9.0.1

tony:~ xdwang$ virtualenv --system-site-packages -p python3 /var/app/software/tensorflow/
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6'
New python executable in /var/app/software/tensorflow/bin/python3.6
Also creating executable in /var/app/software/tensorflow/bin/python
Installing setuptools, pip, wheel…done.

tony:~ xdwang$ source /var/app/software/tensorflow/bin/activate
(tensorflow) tony:~ xdwang$ easy_install -U pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
Best match: pip 9.0.1
Processing pip-9.0.1.tar.gz
Writing /var/folders/0z/lfhw5hfn36zggb7cj6lkz43m0000gn/T/easy_install-rz0op5_h/pip-9.0.1/setup.cfg
Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /var/folders/0z/lfhw5hfn36zggb7cj6lkz43m0000gn/T/easy_install-rz0op5_h/pip-9.0.1/egg-dist-tmp-lxopbz_5
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
creating /private/var/app/software/tensorflow/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg
Extracting pip-9.0.1-py3.6.egg to /private/var/app/software/tensorflow/lib/python3.6/site-packages
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /var/app/software/tensorflow/bin
Installing pip3 script to /var/app/software/tensorflow/bin
Installing pip3.6 script to /var/app/software/tensorflow/bin

Installed /private/var/app/software/tensorflow/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg
Processing dependencies for pip
Finished processing dependencies for pip

(tensorflow) tony:~ xdwang$ pip3 install --upgrade tensorflow
Collecting tensorflow
Downloading tensorflow-1.3.0-cp36-cp36m-macosx_10_11_x86_64.whl (39.8MB)
100% |████████████████████████████████| 39.8MB 30kB/s
Requirement already up-to-date: wheel>=0.26 in /private/var/app/software/tensorflow/lib/python3.6/site-packages (from tensorflow)
Collecting protobuf>=3.3.0 (from tensorflow)
Downloading protobuf-3.4.0-py2.py3-none-any.whl (375kB)
100% |████████████████████████████████| 378kB 153kB/s
Collecting tensorflow-tensorboard<0.2.0,>=0.1.0 (from tensorflow)
Downloading tensorflow_tensorboard-0.1.8-py3-none-any.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 191kB/s
Collecting six>=1.10.0 (from tensorflow)
Downloading six-1.11.0-py2.py3-none-any.whl
Collecting numpy>=1.11.0 (from tensorflow)
Downloading numpy-1.13.3-cp36-cp36m- macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB)
100% |████████████████████████████████| 4.6MB 114kB/s
Requirement already up-to-date: setuptools in /private/var/app/software/tensorflow/lib/python3.6/site-packages (from protobuf>=3.3.0->tensorflow)
Collecting html5lib==0.9999999 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading html5lib-0.9999999.tar.gz (889kB)
100% |████████████████████████████████| 890kB 119kB/s
Collecting werkzeug>=0.11.10 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
100% |████████████████████████████████| 317kB 143kB/s
Collecting markdown>=2.6.8 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading Markdown-2.6.9.tar.gz (271kB)
100% |████████████████████████████████| 276kB 162kB/s
Collecting bleach==1.5.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow)
Downloading bleach-1.5.0-py2.py3-none-any.whl
Building wheels for collected packages: html5lib, markdown
Running setup.py bdist_wheel for html5lib ... done
Stored in directory: /Users/xdwang/Library/Caches/pip/wheels/6f/85/6c/56b8e1292c6214c4eb73b9dda50f53e8e977bf65989373c962
Running setup.py bdist_wheel for markdown ... done
Stored in directory: /Users/xdwang/Library/Caches/pip/wheels/bf/46/10/c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
Successfully built html5lib markdown
Installing collected packages: six, protobuf, html5lib, werkzeug, markdown, bleach, numpy, tensorflow-tensorboard, tensorflow
Successfully installed bleach-1.5.0 html5lib-0.9999999 markdown-2.6.9 numpy-1.13.3 protobuf-3.4.0 six-1.11.0 tensorflow-1.3.0 tensorflow-tensorboard-0.1.8 werkzeug-0.12.2

(tensorflow) tony:~ xdwang$ python3
Python 3.6.3 (default, Oct 4 2017, 06:09:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
/>>> import tesnorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tesnorflow'
/>>> import tensorflow as tf
/>>> hello=tf.constant('hello,tensorflow')
/>>> sess=tf.Session()
2017-10-26 19:21:48.857584: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-26 19:21:48.857625: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-10-26 19:21:48.857641: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-26 19:21:48.857655: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
/>>> print(sess.run(hello))
b'hello,tensorflow'

  • 啟動tensorflow
    執行source /var/app/software/tensorflow/bin/activate腳本啟動tensorflow
    tony:dl xdwang$ pwd
    /Users/xdwang/dl
    tony:dl xdwang$ ls
    fibo.py test1.py xianxinghuigui2.py
    tony:dl xdwang$ source /var/app/software/tensorflow/bin/activate
    (tensorflow) tony:dl xdwang$ pwd
    /Users/xdwang/dl
    (tensorflow) tony:dl xdwang$

在tensorflow虛擬機下安裝IPython

source /var/app/software/tensorflow/bin/activate
(tensorflow) tony:~ xdwang$ pip3 install ipython
note:在tensorflow虛擬機中安裝ipython之后,在intellij工程中引用import IPython就不會報錯了。

tensorflow和intellij ieda集成設置

在intellij中集成tensorflow的步驟:
1,安裝tensorflow3
2,安裝intellij idea
3,在intellij idea中創建一個工程,在工程的 中指定Python SDK home path:/var/app/software/tensorflow/bin/python3.6
注:如果不知道tensorflow路徑,可以寫如下代碼
(tensorflow) tony:~ xdwang$ python3
import tensorflow as tf
tf.version
'1.3.0'
tf.path
['/var/app/software/tensorflow/lib/python3.6/site-packages/tensorflow']

4,寫一段測試代碼試一下是否好使
import tensorflow as tf
hello=tf.constant('helloword')
sess=tf.Session()
print(sess.run(hello))


sennchi

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 227,837評論 6 531
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,196評論 3 414
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 175,688評論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,654評論 1 309
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,456評論 6 406
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 54,955評論 1 321
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,044評論 3 440
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,195評論 0 287
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,725評論 1 333
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,608評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,802評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,318評論 5 358
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,048評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,422評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,673評論 1 281
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,424評論 3 390
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,762評論 2 372

推薦閱讀更多精彩內容