Ubuntu14.10安装TensorFlow1.0.1

本文记录了在Ubuntu上安装TensorFlow的步骤。
系统环境:Ubuntu14.10 64bit
Python版本:Python 2.7.8
TensorFlow版:TensorFlow 1.0.1html

安装步骤

1. 检查Python和pip的版本

因为本系统以前已经安装了Python,这里只须要确认一下版本号。python

$ python -V

输出:Python 2.7.8linux

$ pip -V

输出:pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)git

2. 安装virtualenv

$ sudo pip install virtualenv

输出:Successfully installed virtualenv-15.1.0github

3. 建立虚拟环境

$ virtualenv --system-site-packages ~/tf101py27

上述命令在~/tf101py27目录下建立了一个虚拟环境。输出:
New python executable in /home/tsiangleo/tf101py27/bin/python
Installing setuptools, pip, wheel...done.api

4. 激活(进入)虚拟环境

$ source ~/tf101py27/bin/activate

上述命令执行后的输出以下:ruby

(tf101py27) tsiangleo@hadoop:~$

此时系统进入了虚拟环境,后续就在该虚拟环境下安装软件,和正常的安装过程同样。python2.7

5. 安装TensorFlow1.0.1

# Ubuntu/Linux 64-bit, CPU only, Python 2.7 (tf101py27) tsiangleo@hadoop:~$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl

上面的命令可能会报错参考Blog: SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
可先将whl包下载下来,而后进行安装,以下所示:oop

(tf101py27) tsiangleo@hadoop:~$ wget https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl (tf101py27) tsiangleo@hadoop:~$ pip install --upgrade tensorflow-1.0.1-cp27-none-linux_x86_64.whl

这个过程要持续一段时间,系统会下载相关的依赖包,好比numpy等。
安装成功后输出:Successfully installed numpy-1.12.1 pbr-3.0.0 protobuf-3.2.0 tensorflow-1.0.1google

6. 验证TensorFlow是否安装成功

(tf101py27) tsiangleo@hadoop:~/tf101py27$ python Python 2.7.8 (default, Jun 18 2015, 18:54:19) [GCC 4.9.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> tf.__version__ '1.0.1' >>>

7. 退出虚拟环境

(tf101py27) tsiangleo@hadoop:~/tf101py27$ deactivate

参考文档

https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup

相关文章
相关标签/搜索