Open Actor12 opened 3 years ago
把SyncBatchNorm轉回BatchNorm可以解決
I am confused : How to convert SyncBatchNorm to BatchNorm. Could you please tie codes, THKs
I am confused : How to convert SyncBatchNorm to BatchNorm. Could you please tie codes, THKs
I changed the pytorch version and solved it, torch==1.3 && torchvision==0.4.2
@WongKinYiu ,"把SyncBatchNorm轉回BatchNorm可以解決", but the common.py use BatchNorm2d, not use SyncBatchNorm,how to convert SyncBatchNorm to BatchNorm? thx
i use cpu to run test.py ,get this error:
Traceback (most recent call last):
File "test.py", line 281, in
:~/myProjects/ScaledYOLOv4-yolov4-large# python test.py --img 896 --conf 0.001 --batch 1 --device 0 --data data/coco.yaml --weights weights/yolov4-p5.pt
Namespace(augment=False, batch_size=1, conf_thres=0.001, data='data/coco.yaml', device='0', img_size=896, iou_thres=0.65, merge=False, save_json=True, save_txt=False, single_cls=False, task='val', verbose=False, weights=['weights/yolov4-p5.pt']) Using CUDA device0 _CudaDeviceProperties(name='Tesla V100-PCIE-16GB', total_memory=16130MB)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'models.yolo.Model' has changed. you can retrieve the original source code by accessing the object's source attribute or set
opt.verbose)
File "test.py", line 74, in test
_ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 109, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 129, in forward_once
x = m(x) # run
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, *kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/common.py", line 66, in forward
return self.cv4(self.act(self.bn(torch.cat((y1, y2), dim=1))))
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(input, kwargs)
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 430, in forward
raise AttributeError('SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel')
AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel
root@wufei-jupyter-nchkw:~/myProjects/ScaledYOLOv4-yolov4-large# python test.py --img 896 --conf 0.001 --batch 8 --device 0 --data coco.yaml --weights weights/yolov4-p5.pt
Namespace(augment=False, batch_size=8, conf_thres=0.001, data='./data/coco.yaml', device='0', img_size=896, iou_thres=0.65, merge=False, save_json=True, save_txt=False, single_cls=False, task='val', verbose=False,weights=['weights/yolov4-p5.pt'])
Using CUDA device0 _CudaDeviceProperties(name='Tesla V100-PCIE-16GB', total_memory=16130MB)
torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing theobject's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.SyncBatchNorm' has changed. you can retrieve the original source code by accessing the object's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.ModuleList' has changed. you can retrieve the original source code by accessing the object's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) Fusing layers... Model Summary: 331 layers, 7.07943e+07 parameters, 6.81919e+07 gradients Traceback (most recent call last): File "test.py", line 278, in/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'models.yolo.Model' has changed. you can retrieve the original source code by accessing the object's source attribute or set
opt.verbose)
File "test.py", line 74, in test
_ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 109, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 129, in forward_once
x = m(x) # run
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, *kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/common.py", line 66, in forward
return self.cv4(self.act(self.bn(torch.cat((y1, y2), dim=1))))
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(input, kwargs)
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 430, in forward
raise AttributeError('SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel')
AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel
torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing theobject's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.SyncBatchNorm' has changed. you can retrieve the original source code by accessing the object's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.ModuleList' has changed. you can retrieve the original source code by accessing the object's source attribute or settorch.nn.Module.dump_patches = True
and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) Fusing layers... Model Summary: 331 layers, 7.07943e+07 parameters, 6.81919e+07 gradients Traceback (most recent call last): File "test.py", line 278, in