ubuntu 16.04 安装Tensorflow

ubuntu 16.04 安装Tensorflow(CPU)

安装python

ubuntu 16.04自带python2.7,因此可以略过这一步

安装pip

sudo apt-get install python-pip python-dev

安装tensorflow

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

在国内google网站访问可能比较慢,如果出现网络错误的话多试几次就ok了。

测试

进入python,输入一下命令

import tensorflow as tf
a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')
c = a + b
print(c)

输出一下结果,表示安装成功

Tensor("add:0", shape=(3,), dtype=float32)