Tensorflow安裝手冊(cè)

Tensorflow安裝手冊(cè)

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'

  • 啟動(dòng)tensorflow
    執(zhí)行source /var/app/software/tensorflow/bin/activate腳本啟動(dòng)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虛擬機(jī)下安裝IPython

source /var/app/software/tensorflow/bin/activate
(tensorflow) tony:~ xdwang$ pip3 install ipython
note:在tensorflow虛擬機(jī)中安裝ipython之后吼肥,在intellij工程中引用import IPython就不會(huì)報(bào)錯(cuò)了窗价。

tensorflow和intellij ieda集成設(shè)置

在intellij中集成tensorflow的步驟:
1体斩,安裝tensorflow3
2漂辐,安裝intellij idea
3免钻,在intellij idea中創(chuàng)建一個(gè)工程外莲,在工程的 中指定Python SDK home path:/var/app/software/tensorflow/bin/python3.6
注:如果不知道tensorflow路徑酸员,可以寫(xiě)如下代碼
(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滞造,寫(xiě)一段測(cè)試代碼試一下是否好使
import tensorflow as tf
hello=tf.constant('helloword')
sess=tf.Session()
print(sess.run(hello))


sennchi

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末路召,一起剝皮案震驚了整個(gè)濱河市勃刨,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌股淡,老刑警劉巖身隐,帶你破解...
    沈念sama閱讀 211,123評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異唯灵,居然都是意外死亡贾铝,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門(mén)埠帕,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)垢揩,“玉大人,你說(shuō)我怎么就攤上這事敛瓷∪蓿” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 156,723評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵呐籽,是天一觀的道長(zhǎng)锋勺。 經(jīng)常有香客問(wèn)我蚀瘸,道長(zhǎng),這世上最難降的妖魔是什么庶橱? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,357評(píng)論 1 283
  • 正文 為了忘掉前任贮勃,我火速辦了婚禮,結(jié)果婚禮上苏章,老公的妹妹穿的比我還像新娘寂嘉。我一直安慰自己,他們只是感情好布近,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,412評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布垫释。 她就那樣靜靜地躺著,像睡著了一般撑瞧。 火紅的嫁衣襯著肌膚如雪棵譬。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 49,760評(píng)論 1 289
  • 那天预伺,我揣著相機(jī)與錄音订咸,去河邊找鬼。 笑死酬诀,一個(gè)胖子當(dāng)著我的面吹牛脏嚷,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播瞒御,決...
    沈念sama閱讀 38,904評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼父叙,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了肴裙?” 一聲冷哼從身側(cè)響起趾唱,我...
    開(kāi)封第一講書(shū)人閱讀 37,672評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎蜻懦,沒(méi)想到半個(gè)月后甜癞,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,118評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡宛乃,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,456評(píng)論 2 325
  • 正文 我和宋清朗相戀三年悠咱,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片征炼。...
    茶點(diǎn)故事閱讀 38,599評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡析既,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出谆奥,到底是詐尸還是另有隱情眼坏,我是刑警寧澤,帶...
    沈念sama閱讀 34,264評(píng)論 4 328
  • 正文 年R本政府宣布雄右,位于F島的核電站空骚,受9級(jí)特大地震影響纺讲,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜囤屹,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,857評(píng)論 3 312
  • 文/蒙蒙 一熬甚、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧肋坚,春花似錦乡括、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,731評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至铣鹏,卻和暖如春敷扫,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背诚卸。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,956評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工葵第, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人合溺。 一個(gè)月前我還...
    沈念sama閱讀 46,286評(píng)論 2 360
  • 正文 我出身青樓卒密,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親棠赛。 傳聞我的和親對(duì)象是個(gè)殘疾皇子哮奇,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,465評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容