(已解决)多卡训练时报错RuntimeError: grad can be implicitly created only for scalar outputs
背景博主第一次使用多卡训练,在程序中添加了如下代码#包装为并行风格模型os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"os.environ["CUDA_VISIBLE_DEVICES"]='0,1,2,3'device_ids=[0,1,2,3]model.to("cuda:0")model=torch.nn.DataParallel(model,devic