这篇文章只是对自己搭建过程的一个记录,更完善的步骤及方法当然是在官网啦
TensorFlow安装步骤-官网
一,操作系统
Ubuntu 16.04 or later (64-bit)
ubuntu默认安装了python3和python2,这样可以省去安装python的步骤
如图所示查看python的版本:

二,安装python pip 及其他必要工具
pip 是 Python 包管理工具,该工具提供了对Python 包的查找、下载、安装、卸载的功能
sudo apt update
sudo apt install python-dev python-pip
sudo pip install -U virtualenv
如apt源不可用,进入下面的网站,复制源列表
apt国内源,里面有更详细的步骤
更改 /etc/apt/source.list 中的内容,并执行下面命令
sudo apt-get update
这样就可以安装 pip了,也可以安装其他的软件如vim
三,安装TensorFlow( 官网是建议创建一个虚拟环境)
创建虚拟环境
virtualenv --system-site-packages -p ./venv(虚拟环境的名称,可任意)
进入虚拟环境
source ./venv/bin/activate
在虚拟环境中安装pip
pip install --upgrade pip
安装tensorflow
pip install --upgrade tensorflow
退出虚拟环境
deactivate
四,HelloWorld
在任意地方新建hello.py文本文件,输入以下内容:
#-*- coding: UTF-8 -*-
import tensorflow as tf
hw =tf.constant("hello world!!")
sess = tf.Session()
print sess.run(hw)
sess.close()
进入python的虚拟环境,执行该代码

输出以下内容,说明安装成功:

网友评论