How to deal with the error:AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel
here are the details:
when run : python tools/test.py --cfg experiments/cityscapes/seg_hrnet_w48_train_512x1024_sgd_lr1e-2_wd5e-4_bs_12_epoch484.yaml
TEST.MODEL_FILE hrnet_cs_8090_torch11.pth
TEST.SCALE_LIST 0.5,0.75,1.0,1.25,1.5,1.75
TEST.FLIP_TEST True
=> init weights from normal distribution Traceback (most recent call last): File "tools/test.py", line 139, in <module> main() File "tools/test.py", line 71, in main logger.info(get_model_summary(model.cuda(), dump_input.cuda())) File "/users/guozibin/dukaiyang/5.11.depth-net-train/HRNet-Semantic-Segmentation-HRNet-OCR/tools/../lib/utils/modelsummary.py", line 90, in get_model_summary model(*input_tensors) File "/users/guozibin/.conda/envs/henet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/users/guozibin/dukaiyang/5.11.depth-net-train/HRNet-Semantic-Segmentation-HRNet-OCR/tools/../lib/models/seg_hrnet.py", line 418, in forward x = self.bn1(x) File "/users/guozibin/.conda/envs/henet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/users/guozibin/.conda/envs/henet/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 438, in forward raise AttributeError('SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel') AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel
Maybe in bn_helper.py: # BatchNorm2d_class = BatchNorm2d = torch.nn.SyncBatchNorm BatchNorm2d_class = BatchNorm2d = torch.nn.BatchNorm2d