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:
C:> conda create -n tensorflow pip python=3.6
Activate the conda environment by issuing the following command:
C:> activate tensorflow
(tensorflow)C:> # Your prompt should change
Issue the appropriate command to install TensorFlow inside your conda environment. To install the CPU-only version of TensorFlow, enter the following command:
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow
To install the GPU version of TensorFlow, enter the following command (on a single line):
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu
验证是否安装成功:
在命令行输入
python
启动Python
接着输入
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
如果输出:
Hello, TensorFlow!
那么安装成功!
网友评论