美文网首页TensorFlow技术帖
Mac OS下安装TensorFlow

Mac OS下安装TensorFlow

作者: techhow | 来源:发表于2017-12-01 20:41 被阅读0次

这里采用virtualenv的方式进行安装。

  1. 安装pip和virtualenv环境
$ sudo easy_install pip
$ pip install --upgrade virtualenv 
  1. 创建一个带有python3的虚拟环境,命名为tensorflow
$ virtualenv --system-site-packages -p python3 tensorflow
  1. 激活虚拟环境
$ source ~/tensorflow/bin/activate 
  1. 确保pip的版本
(tensorflow)$ easy_install -U pip
  1. 安装tensorflow
(tensorflow)$ pip3 install --upgrade tensorflow 
  1. 确保tensorflow安装正确,可以试试下面的小程序
(tensorflow)$ Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
  1. 退出虚拟环境
(tensorflow)$ deactivate
  1. 删除虚拟环境
$ rm -rf tensorflow

参考资料

  1. tensorflow tutorial

相关文章

网友评论

    本文标题:Mac OS下安装TensorFlow

    本文链接:https://www.haomeiwen.com/subject/kitgbxtx.html