国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

學習tensorflow之mac上安裝tensorflow

2019-11-14 16:54:32
字體:
來源:轉載
供稿:網友

tensorflow

背景

聽說谷歌的第二代機器學習的框架tensorflow開源了,我也心血來潮去探探大牛的產品.怎奈安裝就折騰了一天,現在整理出來備忘.

tensorflow官方網站給出的安裝步驟很簡單:

# Only CPU-version is available at the moment.$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

安裝pip

用到了一個pip的工具,查了一下pip類似RedHat里面的yum,安裝Python包非常方便.

好吧,那就裝一個pip.pip的安裝方法也很簡單,就是前提需要先安裝python.然后去下載pip的安裝包,pip安裝命令如下:

qyfmac$ tar zxvf pip-7.1.2.tar.gzqyfmac$ cd pip-7.1.2qyfmac$ python setup.py install

安裝時報錯了:

qyfmac$ python setup.py installrunning installChecking .pth file support in /Library/Python/2.7/site-packages/error: can't create or remove files in install directoryThe following error occurred while trying to add or remove files in theinstallation directory:    [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-38643.pth'The installation directory you specified (via --install-dir, --PRefix, orthe distutils default setting) was:    /Library/Python/2.7/site-packages/Perhaps your account does not have write access to this directory?  If theinstallation directory is a system-owned directory, you may need to sign inas the administrator or "root" account.  If you do not have administrativeaccess to this machine, you may wish to choose a different installationdirectory, preferably one that is listed in your PYTHONPATH environmentvariable.For information on other options, you may wish to consult thedocumentation at:  https://pythonhosted.org/setuptools/easy_install.htmlPlease make the appropriate changes for your system and try again.

里面有個Permission denied意思是權限不足,我們加個sudo繼續執行.

qyfmac$ sudo python setup.py install

安裝完后執行命令pip freeze列出安裝的packages驗證一下pip安裝好沒.

qyfmac$ pip freezealtgraph==0.10.2bdist-mpkg==0.5.0bonjour-py==0.3macholib==1.5.1matplotlib==1.3.1modulegraph==0.10.4numpy==1.10.1py2app==0.7.3...

列出了好多包,我唯一沒搞懂的就是我什么時候裝了這么多包.

安裝tensorflow

到了我們的主角出場了.執行安裝命令安裝tensorflow.

qyfmac$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl

悲劇依舊發生了,googleapis.com這個鬼要弄把梯子才能訪問,下載各種超時.

黃天不負苦心人,有一有心人已經下好并上傳的了百度云 http://pan.baidu.com/s/1ntjaMnf 密碼:sznb.

下載下來安裝之.

qyfmac$ pip install --upgrade tensorflow-0.5.0-py2-none-any.whl

安裝virtualenv

virtualenv是python的沙箱工具.我們畢竟是在自己機器上做實驗,為了不來回修改各種環境變量,我們一般還是弄個沙箱完比較好.測試完直接刪除就行,不用再去改各種配置文件.

用pip命令來安裝:

qyfmac$ sudo pip install --upgrade virtualenv

安裝好后創建一個工作目錄,我直接在home里創建了個文件夾.

qyfmac$ virtualenv --system-site-packages ~/tensorflow

然后進入目錄激活沙箱.

qyfmac$ cd ~/tensorflowqyfmac$ source bin/activate (tensorflow) qyfmac$ 

在virtualenv里安裝tensorflow

把下載下來的tensorflow-0.5.0-py2-none-any.whl文件放到~/tensorflow目錄里.
進入沙箱后,執行命令來安裝tensorflow在沙箱中.

(tensorflow) qyfmac$ pip install --upgrade tensorflow-0.5.0-py2-none-any.whl

運行tensorflow

我是在virtualenv里運行的.直接在系統里執行方式是一樣的.

照著官方文檔敲了個簡單例子.

(tensorflow) qyfmac$ pythonPython 2.7.10 (default, Aug 22 2015, 20:33:39)[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import tensorflow as tf>>> hello = tf.constant('Hello,TensorFlow!')>>> sess = tf.session()>>> print sess.run(hello)Hello, TensorFlow!>>> 

在敲see = tf.Session()這行時會報一個錯

can't determine number of CPU cores: assuming 4 I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 4can't determine number of CPU cores: assuming 4I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 4

可以先不用理會,不影響最終執行結果.

參考

關于作者


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 刚察县| 枝江市| 丽江市| 来宾市| 绥中县| 三亚市| 凤山县| 隆昌县| 垫江县| 黑龙江省| 榆中县| 邵武市| 平顺县| 石阡县| 宣化县| 项城市| 眉山市| 华坪县| 长阳| 桐庐县| 安阳市| 上杭县| 和田市| 肥城市| 米易县| 连南| 平和县| 射洪县| 绥江县| 新营市| 炎陵县| 贺兰县| 太湖县| 清远市| 千阳县| 隆回县| 上杭县| 祁门县| 彭山县| 宣威市| 营口市|