📜  pytorch 检查 gpu - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:21.386000             🧑  作者: Mango

代码示例5
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
#或device = torch.device("cuda:0")
device1 = torch.device("cuda:1")  
for batch_idx, (img, label) in enumerate(train_loader):
    img=img.to(device)
    label=label.to(device)