Ubuntu下配置TensorFlow是很简单的,但是很多资料比较老,而且不是官方的配置过程,可能让读者不知道具体怎么操作,本文将严格参考官方配置过程,说明TensorFlow r1.0(最新版本是TensorFlow r1.4)的安装步骤。
1.配置环境
虚拟机:VMware Workstation 12 Player
操作系统:Ubuntu 16.0 LTS (ubuntu-16.04.1-desktop-amd64.iso)
2.安装步骤
Installing TensorFlow on Ubuntu
2.1 首先根据你的电脑情况选择安装CPU版还是GPU版
如果你的电脑上有NVIDIA的GPU,那么你就可以安装GPU版本,GPU版本性能比CPU版本高很多。
2.2 virtualenv 虚拟环境安装
We recommend the virtualenv installation
安装命令:
sudo apt-get install python3
sudo apt-get install python3-pip
sudo pip3 install virtualenv
virtualenv env
env/bin/pip install matplotlib
env/bin/pip install numpy
env/bin/pip install scipy
env/bin/pip install scikit-image
$ virtualenv --system-site-packages -p python3 ~/tensorflow # for Python 3.n
$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
Ensure pip ≥8.1 is installed:可以使用env/bin/pip list 命令查看
(tensorflow)$ easy_install -U pip
(tensorflow)$ pip3 install --upgrade tensorflow # for Python 3.n
或者
$ pip3 install --upgrade \
https://storage.googleapis.com/tensorflow/linux/cpu/protobuf-3.1.0-cp35-none-linux_x86_64.whl
3. 测试
$ python
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
开始你的AI之旅吧,fighting!