Failed to load model trained by DDP for inference

I have resolved the issues. It’s related to 1686

state_dict = torch.load(weight_path)

from collections import OrderedDict
new_state_dict = OrderedDict()
for k, v in state_dict.items():
    name = k[7:] # remove 'module.' of DataParallel/DistributedDataParallel
    new_state_dict[name] = v

m.load_state_dict(new_state_dict)