您的位置:首页 > 其它

Mac OS X 下安装 TensorFlow

2017-09-26 23:11 381 查看
-首先根据https://zhuanlan.zhihu.com/p/28362186中给出的步骤实现

·1.2版本开始,Mac OS X 上TensorFlow不再支持GPU

·有四种安装方式:

·virtualenv

·本地 pip

·Docker

·从源代码安装

其中推荐了virtualenv,我也是使用了这种方法,十分简便没有出什么问题 // 与其他python项目开发隔离的虚拟python环境,安装的有TensorFlow 和它的所有依赖包

1.打开终端,首先安装pip和virtualenv

$ sudo easy_install pip
$ sudo pip install --upgrade virtualenv

2.创建虚拟环境(择一)
$ virtualenv --system-site-packages targetDirectory # for Python 2.7
$ virtualenv --system-site-packages -p python3 targetDirectory # for Python 3.n在此处,根据教程将targetDirectory设置为 ~/tensorflow
3.激活虚拟环境

$ source ~/tensorflow/bin/activate # If using bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh # If using csh or tcsh

4.若已经安装了pip8.1或者更新的版本,则可以用以下命令在激活的虚拟环境中安装tensorflow即其所有依赖
$ pip install --upgrade tensorflow # for Python 2.7
$ pip3 install --upgrade tensorflow # for Python 3.n

至此,就安装完毕了~

⚠️每次打开终端,想要使用tensorflow时,都需要激活虚拟环境

$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh # csh or tcsh

当提示符变为以下说明已经激活
(tensorflow)$


退出环境
(tensorflow)$ deactivate


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: