TensorFlow入門:Ubuntu 16.04安裝TensorFlow(Anaconda,非GPU)

1.已經在Ubuntu下安裝好了Anaconda。python

2.建立TensorFlow環境,Python2.7linux

Conda create -n tensorflow python=2.7

此時會conda下載安裝python2.7的環境sql

The following NEW packages will be INSTALLED:

    certifi:    2016.2.28-py27_0
    openssl:    1.0.2l-0        
    pip:        9.0.1-py27_1    
    python:     2.7.13-0        
    readline:   6.2-2           
    setuptools: 36.4.0-py27_0   
    sqlite:     3.13.0-0        
    tk:         8.5.18-0        
    wheel:      0.29.0-py27_0   
    zlib:       1.2.11-0        

Proceed ([y]/n)? y

Fetching packages ...
openssl-1.0.2l 100% |################################| Time: 0:00:01   1.77 MB/s
zlib-1.2.11-0. 100% |################################| Time: 0:00:00 191.63 kB/s
python-2.7.13- 100% |################################| Time: 0:00:05   2.31 MB/s
certifi-2016.2 100% |################################| Time: 0:00:00 315.92 kB/s
wheel-0.29.0-p 100% |################################| Time: 0:00:00 174.28 kB/s
setuptools-36. 100% |################################| Time: 0:00:01 529.64 kB/s
pip-9.0.1-py27 100% |################################| Time: 0:00:02 655.58 kB/s
Extracting packages ...
[      COMPLETE      ]|###################################################| 100%
Linking packages ...
[      COMPLETE      ]|###################################################| 100%
#
# To activate this environment, use:
# > source activate tensorflow
# To deactivate this environment, use:
# > source deactivate tensorflow
#

此時在Anaconda的env文件夾下會安裝好TensorFlow文件夾及環境軟件。api

3.按須要激活tensorflow環境,並在此環境下安裝tensorflow:python2.7

wangjc@wangjc-Inspiron-3668:~$ source activate tensorflow
(tensorflow) wangjc@wangjc-Inspiron-3668:~$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl

若是是Python3.5,則以下代碼安裝:this

pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-0.12.0-cp35-cp35m-linux_x86_64.whl

安裝成功:google

Installing collected packages: numpy, six, wheel, setuptools, protobuf, tensorflow
Successfully installed numpy-1.13.1 protobuf-3.0.0b2 setuptools-36.4.0 six-1.10.0 tensorflow-0.8.0rc0 wheel-0.29.0
(tensorflow) wangjc@wangjc-Inspiron-3668:~$ 

4.嘗試加載tensorflow:須要先激活tensorflow環境.net

wangjc@wangjc-Inspiron-3668:~$ source activate tensorflow
(tensorflow) wangjc@wangjc-Inspiron-3668:~$ python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow
>>> 

加載成功!code

 

5.爲了使用spyder,須要在tensorflow環境下安裝spyder:orm

(tensorflow) wangjc@wangjc-Inspiron-3668:~$ conda install -n tensorflow spyder
Fetching package metadata .......
Solving package specifications: ..........

Package plan for installation in environment /home/wangjc/anaconda3/envs/tensorflow:

The following packages will be downloaded:

安裝成功以後在tensorflow環境下運行spyder便可:

若是不在tensorflow環境下安裝spyder,直接運行spyder時打開的可能不是tensorflow對應的python內核。

wangjc@wangjc-Inspiron-3668:~$ source activate tensorflow
(tensorflow) wangjc@wangjc-Inspiron-3668:~$ spyder

 

 各類TensorFlow版本地址鏡像

 

 

 

參考網址

相關文章
相關標籤/搜索