判断机器学习中GPU是否可用
#tensorlfow
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
tf.test.is_gpu_available()
#pytorch
import torch
torch.cuda.is_available()
配置情况:python3.8.8 + tensorflow2.4.1 + cuda11.0 + cudnn8.0.3 可用