HRNet / HRNet-Semantic-Segmentation

The OCR approach is rephrased as Segmentation Transformer: https://arxiv.org/abs/1909.11065. This is an official implementation of semantic segmentation for HRNet. https://arxiv.org/abs/1908.07919
Other
3.09k stars 683 forks source link

How to deal with the error:AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel #227

Open alexanderuo opened 3 years ago

alexanderuo commented 3 years ago

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

shata-wh commented 2 years ago

Maybe in bn_helper.py:

BatchNorm2d_class = BatchNorm2d = torch.nn.SyncBatchNorm

BatchNorm2d_class = BatchNorm2d = torch.nn.BatchNorm2d