方式一
tudui = Tudui()
if torch.cuda.is_available():
tudui = tudui.cuda (网络调用cuda后要再返回给网络)
..........................................................................................
if torch.cuda.is_available():
loss = loss.cuda()
..........................................................................................
if torch.cuda.is_available():
imgs = imgs.cuda()
targets = targets.cuda()
方式二
放开头
device = torch.device('cuda')
..........................................................................................
‘tudui = Tudui()
tudui = tudui.to(device)
..........................................................................................
loss = loss.to(device)
..........................................................................................
images = images.to(device)
targets = targets.to(device)
版权声明:本文为CSDN博主「xiao_bai_bu_hei」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xiao_bai_bu_hei/article/details/122496915
暂无评论