TensorFlow安装,基于 VirtualEnv (Ubuntu14.04 64位 cpu)

来源:互联网 发布:qq空间个性域名注销 编辑:程序博客网 时间:2024/05/17 22:38

TensorFlow基于 VirtualEnv 的安装

环境:ubuntu14.04 64位;python2.7
相关:https://github.com/tensorflow/tensorflow
使用 virtualenv 创建一个隔离的容器, 来安装 TensorFlow。这样做能使排查安装问题变得更容易。

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

$ sudo apt-get install python-pip python-dev python-virtualenv

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

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

然后, 激活 virtualenv :
对于python2.7,执行如下命令:

lwp@lw:~/tensorflow$ source bin/activate

在 virtualenv 内,安装 TensorFlow :
一直用的caffe,这次想了解下tensorflow就简单装了cpu版本的,gpu版还得配置有点麻烦,之前给caffe配的cuda和cudnn版本也不知道兼不兼容,以后有需要再配。

(tensorflow)lwp@lw:~/tensorflow$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0-cp27-none-linux_x86_64.whl

运行 TensorFlow
打开一个 python 终端:

$ python>>> import tensorflow as tf>>> hello = tf.constant('Hello, TensorFlow!')>>> sess = tf.Session()>>> print sess.run(hello)Hello, TensorFlow!>>> a = tf.constant(10)>>> b = tf.constant(32)>>> print sess.run(a+b)42>>>

装好之后又跑了一次截的图

1 0
原创粉丝点击