pytorch设置gpu

# 获取当前设备
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
原文地址:https://www.cnblogs.com/bincoding/p/14143000.html