学习tensorflow之mac上安装tensorflow
2016-12-19 16:10
381 查看
背景
听说谷歌的第二代机器学习的框架 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[/code]用到了一个 pip 的工具,查了一下pip类似RedHat里面的yum,安装Python包非常方便.
安装pip
好吧,那就装一个pip.pip的安装方法也很简单,就是前提需要先安装python.然后去下载 pip的安装包 ,pip安装命令如下:qyfmac$ tar zxvf pip-7.1.2.tar.gz qyfmac$ cd pip-7.1.2 qyfmac$ python setup.py install
安装时报错了:qyfmac$ python setup.py install running install Checking .pth file support in /Library/Python/2.7/site-packages/ error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation 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, or the distutils default setting) was: /Library/Python/2.7/site-packages/ Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://pythonhosted.org/setuptools/easy_install.html Please make the appropriate changes for your system and try again.
[/code]
里面有个Permission denied意思是权限不足,我们价格sudo继续执行.qyfmac$ sudo python setup.py install
安装完后执行命令pip freeze列出安装的packages验证一下pip安装好没.qyfmac$ pip freeze altgraph==0.10.2 bdist-mpkg==0.5.0 bonjour-py==0.3 macholib==1.5.1 matplotlib==1.3.1 modulegraph==0.10.4 numpy==1.10.1 py2app==0.7.3 ...
列出了好多包,我唯一没搞懂的就是我什么时候装了这么多包.到了我们的主角出场了.执行安装命令安装tensorflow.
安装tensorflowqyfmac$ pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl[/code]
悲剧依旧发生了,googleapis.com这个鬼要弄把梯子才能访问,下载各种超时.
黄天不负苦心人,有一有心人已经下好并上传的了百度云 http://pan.baidu.com/s/1ntjaMnf 密码:sznb.
下载下来安装之.qyfmac$ pip install --upgrade tensorflow-0.5.0-py2-none-any.whlvirtualenv是python的沙箱工具.我们毕竟是在自己机器上做实验,为了不来回修改各种环境变量,我们一般还是弄个沙箱完比较好.测试完直接删除就行,不用再去改各种配置文件.
安装virtualenv
用pip命令来安装:qyfmac$ sudo pip install --upgrade virtualenv
安装好后创建一个工作目录,我直接在home里创建了个文件夹.qyfmac$ virtualenv --system-site-packages ~/tensorflow
然后进入目录激活沙箱.qyfmac$ cd ~/tensorflow qyfmac$ source bin/activate (tensorflow) qyfmac$把下载下来的
在virtualenv里安装tensorflowtensorflow-0.5.0-py2-none-any.whl文件放到~/tensorflow目录里.
进入沙箱后,执行命令来安装tensorflow在沙箱中.(tensorflow) qyfmac$ pip install --upgrade tensorflow-0.5.0-py2-none-any.whl我是在virtualenv里运行的.直接在系统里执行方式是一样的.
运行tensorflow
照着官方文档敲了个 简单例子 .(tensorflow) qyfmac$ python Python 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 darwin Type "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: 4 can't determine number of CPU cores: assuming 4 I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 4
可以先不用理会,不影响最终执行结果.tensorflow官方地址: http://tensorflow.org
参考
tensorflow软件下载地址: http://pan.baidu.com/s/1ntjaMnf 密码:sznb.
pip官方地址: https://pypi.python.org/pypi/pip
setuptools官方地址: https://pypi.python.org/pypi/setuptools
python安装setuptools步骤详解: http://www.111cn.net/phper/python/66848.htm
相关文章推荐
- Ubuntu 16.04安装配置TensorFlow GPU版本
- 什么是Mac OS X?跟Linux有什么区别
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- TensorFlow 的简单例子
- Linux vs Mac:Linux 比 Mac 好的 7 个原因
- 苹果mac OS X上安装metasploit
- Mac OS上安装PostgreSQL的教程
- Validation of viewstate MAC failed.的解决方法
- Mac平台中编译安装Lua运行环境及Hello Lua实例
- 在Mac OS中安装Lua的教程
- MAC上Mysql忘记Root密码或权限错误的快速解决方案
- vbs Windows系统改变或修改网卡的MAC地址的脚本与软件第1/2页
- MAC官方菜单纯CSS实现灰色会换色
- mac系统OS X10.10版本安装最新5.7.9mysql的方法
- MAC下mysql安装配置方法图文教程
- 在Mac OS下使用Node.js的简单教程
- mac 中docker安装mysql的图文教程
- Mac上将brew安装的MySql改用Docker执行操作过程
- Mac环境下php操作mysql数据库的方法分享