tensorflow 2.x判断GPU是否可用的方法

在cmd中输入python,进入到python环境,再输入下面两句
import tensorflow as tf
tf.config.list_physical_devices(‘GPU’)
若输出为
tensorflow 2.x判断GPU是否可用的方法
则说明GPU可用