import tensorflow as tf
tf.compat.v1.disable_eager_execution() #保证sess.run()能够正常运行
hello = tf.constant('hello,tensorflow')
sess= tf.compat.v1.Session()#版本2.0的函数
print(sess.run(hello))
参考win10安装tensorflow2.0-gpu版本以及测试是否安装成功_Be better。的博客-CSDN博客_测试tensorflow-gpu安装成功