tensorflow安装

第三步:检测python是否安装,环境配置是否成功

cmd 》》》python
验证是否安装成功:

这里写图片描述

相关知识插入:
TensorFlow 有两个版本:CPU 版本和 GPU 版本。GPU 版本需要 CUDA 和 cuDNN 的支持,CPU 版本不需要。
如果你要安装 GPU 版本,请先确认你的显卡支持 CUDA。
采用 pip 安装方式,本文安装cpu版本
1.确认版本:pip版本 >= 8.1。用 pip -V 查看当前 pip 版本,用 python -m pip install -U pip 升级pip 。
2.确保你安装了 VS2015 或者 2013 或者 2010。

第四步:TensorFlow安装(我安装的是cpu版本)

以管理员身份运行cmd
cd到这个地址:

cd Program FilesAnaconda3Scripts 
  • 1

输入:

pip install tensorflow
  • 1

补充信息:
一键安装(CPU版):

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

(GPU版)

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

第五步:测试

在cmd输入

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

输出:Hello, TensorFlow!

a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))

第六步:配置PyCharm

打开》》file》》setting》》

在里面新建一个,测试一下:
进入一个交互式 TensorFlow 会话.

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))、
  • 1
  • 2
  • 3
  • 4
结果是:这里写图片描述
原文地址:https://www.cnblogs.com/jojo123/p/6738058.html