报错 AssertionError: Torch not compiled with CUDA enabled

报错:

AssertionError: Torch not compiled with CUDA enabled

本文针对仅有CPU无GPU的设备,针对该报错进行修改:

在代码开头添加:

// A code block
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

代码中出现.cuda()的,替换为

.to(device)

你可能感兴趣的:(深度学习,人工智能,神经网络)