Ubuntu下安装Tensorflow(CPU)
一、更新为阿里云软件源,增加下载速度
(1)备份当前也就是默认官方的源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
(2)删除sources.list文件中的列表,删除全部内容
sudo gedit /etc/apt/sources.list
(3)替换内容后,保存
deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
(4)更新源列表
sudo apt-get update
二、安装Tensorflow(Python3.5.2/CPU)
(1)安装Python3的包管理pip
sudo apt-get install python3-pip python3-dev
(2)安装tensorflow
(自动安装相关库numpy、tensorboard、six、protobuf、html5lib、bleach、werkzeug、markdown)
sudo pip3 install tensorflow
(3)测试tensorflow
import tensorflow as tf
a = tf.constant(1)
b = tf.constant(2)
op = a + b
sess = tf.Session()
sess.run(op)
sess.close()