环境说明

Python3.7
配有Anaconda 且anaconda已安装pip

  1. 查看python版本:python --version
  2. 在Anaconda中安装TensorFlow:pip install tensorflow
  3. 在Anaconda中安装TensorFlow(GPU版本):
  1. 在Anaconda中安装框架keras:pip install keras
  2. 安装好后测试环境:
python
import tensorflow as tf
hello=tf.constant('hello,tensorflow')
sess=tf.Session()
print(sess.run(hello))

上述在执行sess时候出现警告

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

针对方法(小技巧):

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

在执行程序前面加入小技巧即可避免警告

注:没有在Anaconda中另外创建python环境来安装TensorFlow
(直接将在base(root)下,安装了TensorFlow,此时Jupyter以及Spyder使用TensorFlow无需另外配置了)

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐