TensorFlow入门:Ubuntu 16.04安装TensorFlow(Anaconda,非GPU)

1.已经在Ubuntu下安装好了Anaconda。

2.创建TensorFlow环境,Python2.7

Conda create -n tensorflow python=2.7

此时会conda下载安装python2.7的环境

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文件夹及环境软件。

3.按需要激活tensorflow环境,并在此环境下安装tensorflow:

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,则如下代码安装:

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

安装成功:

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环境

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
>>> 

加载成功!

 

5.为了使用spyder,需要在tensorflow环境下安装spyder:

(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版本地址镜像

 

 

 

参考网址

    原文作者:tensorflow
    原文地址: https://www.cnblogs.com/Osler/p/7687170.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞