#测试TensorFlow-GPU是否可用import tensorflow as tfimport osprint(tf.__version__)os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # 不显示等级2以下的提示信息print('GPU', tf.config.list_physical_devices('GPU'))#列出所有的GPU驱动号a = tf.constant(2.0)b = tf.constant(4.0)print(a + b)
输出如下:
