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

相關文章
相關標籤/搜索