1、ValueError: torch.nn.DataParallel is not supported by ONNX exporter, please use 'attribute' module to unwrap model from torch.nn.DataParallel. Try torch.onnx.export(model.module, ...)
多GPU环境下训练的模型在导出onnx文件时,可能会报以上错误。
是因为加载模型前加了此句,model = nn.DataParallel(model)
如果不加,依然报错,如图看到参数字典多了一个module.