本文記錄了在Ubuntu上安裝TensorFlow的步驟陨帆。
系統(tǒng)環(huán)境:Ubuntu14.10 64bit
Python版本:Python 2.7.8
TensorFlow版:TensorFlow 1.0.1
安裝步驟
1. 檢查Python和pip的版本
由于本系統(tǒng)之前已經(jīng)安裝了Python线定,這里只需要確認(rèn)一下版本號(hào)储矩。
$ python -V
輸出:Python 2.7.8
$ pip -V
輸出:pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
2. 安裝virtualenv
$ sudo pip install virtualenv
輸出:Successfully installed virtualenv-15.1.0
3. 創(chuàng)建虛擬環(huán)境
$ virtualenv --system-site-packages ~/tf101py27
上述命令在~/tf101py27目錄下創(chuàng)建了一個(gè)虛擬環(huán)境需纳。輸出:
New python executable in /home/tsiangleo/tf101py27/bin/python
Installing setuptools, pip, wheel...done.
4. 激活(進(jìn)入)虛擬環(huán)境
$ source ~/tf101py27/bin/activate
上述命令執(zhí)行后的輸出如下:
(tf101py27) tsiangleo@hadoop:~$
此時(shí)系統(tǒng)進(jìn)入了虛擬環(huán)境,后續(xù)就在該虛擬環(huán)境下安裝軟件,和正常的安裝過(guò)程一樣。
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
上面的命令可能會(huì)報(bào)錯(cuò)參考Blog: SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
可先將whl包下載下來(lái),然后進(jìn)行安裝印衔,如下所示:
(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
這個(gè)過(guò)程要持續(xù)一段時(shí)間啡捶,系統(tǒng)會(huì)下載相關(guān)的依賴包,比如numpy等奸焙。
安裝成功后輸出:Successfully installed numpy-1.12.1 pbr-3.0.0 protobuf-3.2.0 tensorflow-1.0.1
6. 驗(yàn)證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. 退出虛擬環(huán)境
(tf101py27) tsiangleo@hadoop:~/tf101py27$ deactivate
參考文檔
https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
轉(zhuǎn)載請(qǐng)注明原文出處瞎暑,謝謝!
本文出處:http://www.reibang.com/p/084363c11b18