win10 下 TensorFlow 1.8 CPU 版本安装

2019-02-21  本文已影响0人  XiWeidong

3个步骤:

  1. Python3.6 安装
  2. MSVC 2015 update3
  3. TensorFlow 1.8 安装

1. Python3.6 安装:

https://www.python.org/downloads/windows/

Python3.6下载
下载后直接安装,勾选添加到环境变量Path,确保去掉Path环境里其他的Python

2. MSVC 2015 update3 安装

如果系统没有装过,需要安装一下
下载地址:https://www.microsoft.com/en-us/download/details.aspx?id=53587

image.png

下载后直接安装即可

3. 安装 TensorFlow 1.8:

打开一个cmd,执行下面的命令

pip install tensorflow==1.8 -i https://pypi.tuna.tsinghua.edu.cn/simple

这里要注意的是指定tensorflow的版本是1.8,不指定会安装最新的版本,版本不匹配是跑不起来的
-i https://pypi.tuna.tsinghua.edu.cn/simple 代表我们使用清华的镜像,速度非常快

跑一段简单的代码:

import tensorflow as tf
m1 = tf.constant([[2, 2]])
m2 = tf.constant([[3],
                  [3]])
dot_operation = tf.matmul(m1, m2)
print(dot_operation)  # 这里并没有结果
# 使用seesion ,方法1
sess = tf.Session()
result = sess.run(dot_operation)
print(result)

此图表示执行成功
上一篇 下一篇

猜你喜欢

热点阅读