智健blog

pytorch查看gpu信息,gpu是否可用

import torch
gpu_use= torch.cuda.is_available()
print(gpu_use)
# Decide which device we want to run on
device = torch.device("cuda:0" if (torch.cuda.is_available()) else "cpu")
print(device)
print(torch.cuda.get_device_name(0))
posted @ 2022-06-04 09:45  智健  阅读(356)  评论(0编辑  收藏  举报