tensorFlow on mac

reference : https://www.jianshu.com/p/b7f735930c36
http://blog.csdn.net/u010858605/article/details/64128466

Anaconda 清华镜像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
1、基于 Anaconda 的安装
2、打开shell,添加清华仓库镜像

conda config --add channels      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

3、创建一个python环境

conda create -n tensorflow python=3.6.2

或者通过界面操作

4、启动tensorflow环境

source activate tensorflow

注:当不使用tensorflow时,关闭tensorflow环境,命令为:source deactivate

5、安装cpu版本的TensorFlow

pip install --upgrade --ignore-installed tensorflow

sunMacBook-Pro:~ sun$ source activate tensorflow
(tensorflow) sunBook-Pro:~ sun$ pip install --upgrade --ignore-installed tensorflow

6、测试tensorflow

 (tensorflow) sunkMacBook-Pro:~ sun$ python
     import tensorflow as tf
     hello = tf.constant('Hello, TensorFlow!')
     sess = tf.Session()
     print(sess.run(hello))
--'Hello, TensorFlow!'

启动Spyder IDE

注意:一定要启动tensorflow 环境下的Spyder才可以import tensorflow,不要去开始菜单运行Spyder,在那里是无法运行的,如
这里写图片描述


直接安装
reference : https://github.com/tensorflow/tensorflow
$sudo pip install https://ci.tensorflow.org/view/tf-nightly/job/tf-nightly-mac/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=mac-slave/lastSuccessfulBuild/artifact/pip_test/whl/tf_nightly-1.head-py2-none-any.whl

$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!

Mac系统10.11及以上升级numpy、scipy等python包报错解决方案
点击Mac电脑的苹果图标
选择 重新启动
按住 command+R,直到进入还原模式
选择实用工具,然后点击 终端
输入 csrutil disable 按下回车
重启电脑

  1. 点击Mac电脑的苹果图标
  2. 选择 重新启动
  3. 按住 command+R,直到进入还原模式
  4. 选择实用工具,然后点击 终端
  5. 输入 csrutil enable 按下回车
  6. 重启电脑
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值