tensorflow的程序
import tensorflow as tf
#预期true 检查是否至少有一个gpu可用
tf.test.is_gpu_avaiable()
# 给出第一个 gpu 的名称
tf.test.gpu_device_name()
百度paddle的测试程序
import paddle
print(paddle.device.get_device())
pytorch 的测试程序
import torch
print(torch.cuda.is_available())
print(torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu"))