安装tensorflow(tf版本需要查一下) (1)pip install tensorflow-gpu==2.1.0 --use-feature=2020-resolver -i https://pypi.tuna.tsinghua.edu.cn/simple/ (2)–use-feature=2020-resolver这个参数是因为出现这样的错误 问题描述: 使用pip安装模块时报错: ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts. We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default. 解决方法: 在pip命令中加入–use-feature=2020-resolver参数就可以了, 比如pip install xxx --use-feature=2020-resolver
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
a = tf.constant(1.)
b = tf.constant(2.)print(a+b)print('GPU:', tf.test.is_gpu_available())