使用Anaconda安装TensorFlow

Take the following steps to install TensorFlow in an Anaconda environment:
Follow the instructions on the Anaconda download site to download and install Anaconda.(成功安装了Anaconda之后,在命令行窗口顺序输入一下代码,记得以管理员身份运行)
Create a conda environment named tensorflow by invoking the following command:

1
conda create -n tensorflow pip python=3.6

FgX7z4.md.png

Activate the conda environment by useing the following command:

1
activate tensorflow

Issue the appropriate command to install TensorFlow inside your conda environment. To install the CPU-only version of TensorFlow, enter the following command:

1
pip install --ignore-installed --upgrade tensorflow

To install the GPU version of TensorFlow, enter the following command (on a single line):

1
pip install --ignore-installed --upgrade tensorflow-gpu

验证是否安装成功:
在命令行输入

1
python

启动Python
接着输入

1
2
3
4
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

如果输出:

1
Hello, TensorFlow!

那么安装成功!

Fcubs1.jpg