Windows下TensorFlow安装

来源:互联网 发布:淘宝显示全球购的标志 编辑:程序博客网 时间:2024/05/22 17:30


Windows下安装TensorFlow,由于电脑不支持GPU加速,只能安装CPU版本的了。

在安装TensorFlow之前,需要提前安装Python。

TensorFlow的官方网站被墙了,可以在GetHub上查看其信息。


安装TensorFlow,在控制台执行如下代码:

pip install --upgrade pippip install --upgrade tensorflow

这样安装成功的版本为较新的版本,如果要指定TensorFlow版本,可以执行如下代码:

pip install --upgrade    https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.wh

第一个控制台程序:

Python>>> import tensorflow as tf>>> hello = tf.constant('Hello, TensorFlow!')>>> sess = tf.Session()>>> sess.run(hello)'Hello, TensorFlow!'>>> a = tf.constant(10)>>> b = tf.constant(32)>>> sess.run(a + b)42>>> sess.close()
第一个PyCharm程序:

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