1、修改torch.load torch.load(opt.model, map_location='cpu') 2、将cuda()修改 device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") .cuda() -->(修改为) .to(device)