在Windows中安装TensorFlow

更多的安装方式可参见tensorflow的官网
https://www.tensorflow.org/versions/r0.12/get_started/os_setup

1.TensorFlow supports only 64-bit Python 3.5 on Windows.(目前,在Windows上,TensorFlow只支持64位的Python。)
2.TensorFlow GPU support requires having a GPU card with NVidia Compute Capability (>= 3.0).(只有当GPU的计算能力>=3.0时,TensorFlow才能利用。)
3.Check NVIDIA Compute Capability of your GPU card:https://developer.nvidia.com/cuda-gpus


直接安装TensorFlow:

1.先在windows上安装好Anaconda
2.打开windows的命令行窗口,输入(CPU版本):

pip install tensorflow

若要安装GPU版本(建议先装好Cuda Toolkit 8.0和cuDNN v5),可输入:

pip install tensorflow-gpu

3.(可选)安装keras:

pip install keras

在Conda环境中安装TensorFlow:

1.先在windows上安装好Anaconda
2.打开windows的命令行窗口
3.创建一个名为tf的conda环境,输入:

conda create -n tf python=3.5

4.激活tf的环境,输入:

activate tf

5.为tf环境安装tensorflow(CPU版本):

pip install tensorflow

若要安装GPU版本(建议先装好Cuda Toolkit 8.0和cuDNN v5),可输入:

pip install tensorflow-gpu

6.(可选)为tf环境安装ipython:

conda install ipython

(可选)为tf环境安装Jupyter:

pip install jupyter

7.至此tensorflow已安装完毕,退出tf环境可输入:

deactivate tf

测试安装好的TensorFlow:

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>> exit()

测试TensorFlow


Note:如果你Anaconda的Python版本不是3.5,可以用:conda install python=3.5将Anaconda切换到Python3.5版。

猜你喜欢

转载自blog.csdn.net/cosmoshua/article/details/71194697