美文网首页机器学习
tensorflow mac和Linux上的简便安装

tensorflow mac和Linux上的简便安装

作者: ce0b74704937 | 来源:发表于2019-01-08 11:36 被阅读0次

基于VirtualEnv的安装

首先, 安装所有必备工具:

# 在 Linux 上:
$ sudo apt-get install python-pip python-dev python-virtualenv

# 在 Mac 上:
$ sudo easy_install pip  # 如果还没有安装 pip
$ sudo pip install --upgrade virtualenv

接下来, 建立一个全新的 virtualenv 环境. 为了将环境建在 ~/tensorflow 目录下, 执行:

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

然后, 激活 virtualenv:

$ source bin/activate  # 如果使用 bash
$ source bin/activate.csh  # 如果使用 csh
(tensorflow)$  # 终端提示符应该发生变化

在virtualenv 内, 安装 TensorFlow:

(tensorflow)$ pip install --upgrade <$url_to_binary.whl>

接下来, 使用类似命令运行 TensorFlow 程序:

(tensorflow)$ cd tensorflow/models/image/mnist
(tensorflow)$ python convolutional.py

# 当使用完 TensorFlow
(tensorflow)$ deactivate  # 停用 virtualenv

$  # 你的命令提示符会恢复原样

参考

[1] http://www.tensorfly.cn/tfdoc/get_started/os_setup.html

[2] https://www.tensorflow.org/install/pip?lang=python2

相关文章

网友评论

    本文标题:tensorflow mac和Linux上的简便安装

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