torch中将网络加载进GPU的两种方式

对于网络模型的实例化对象net

一、

import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
net.to(device)

二、

import torch
net.cuda()
原文地址:https://www.cnblogs.com/czz0508/p/10954040.html