pytorch Check the number of GPUs, whether they are available

#cuda是否可用;
torch.cuda.is_available()
# 返回gpu数量;
torch.cuda.device_count()
# 返回gpu名字,设备索引默认从0开始;
torch.cuda.get_device_name(0)
# 返回当前设备索引;
torch.cuda.current_device()

Guess you like

Origin blog.csdn.net/guaizaiguaizai/article/details/121629944