基于Anaconda的TensorFlow安装(Ubuntu 16.04 LTS)

一、安装Anaconda

  从Anaconda官网(https://www.anaconda.com/download)下载linux版本的安装文件(推荐Python2.7 version),在终端中进行安装。

  bash Anaconda2-4.4.0-Linux-x86_64.sh

二、建立一个tensorflow的运行环境

    conda create –n tensorflow python=2.7 

三、在conda环境中安装tensorflow

    (1)**环境

        source activate tensorflow

    (2)安装tensorflow

        pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl  

    (3)退出环境

        source deactivate

四、测试是否安装成功

    (1)**tensorflow环境

       source activate tensorflow

    (2)**Python环境

       python

    (3)测试代码

        import tensorflow as tf

        hello = tf.constant('Hello, TensorFlow!') 

        sess = tf.Session()

        sess.run(hello)

    (4)退出python环境(ctrl+d)

    (5)退出tensorflow环境

        source deactivate


五、Jupyter中使用TensorFlow

    (1)进入tensorFlow环境,安装ipython和jupyter

        conda install ipython  

        conda install jupyter

        conda  install  matplotlib

    (2)运行命令

        ipython kernelspec install-self –user

    (3)进入Jupyter

        jupyter notebook