open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.43k stars 9.43k forks source link

RuntimeError: input tensor has to be contiguous with DCNv2 on Res2Net #3129

Closed zehuichen123 closed 4 years ago

zehuichen123 commented 4 years ago

Hi, I am trying to add DCNv2 on Res2Net backbone. Interestingly, I got an RuntimeError: input tensor has to be contiguous with batch size = 2 but when I set batch size = 1, the error was gone. This bug also didn't appear on DCNv1.

panjianning commented 4 years ago

I met this problem before. Adding this line may help.

zehuichen123 commented 4 years ago

I met this problem before. Adding this line may help.

Thanks! I will give it a try~

hyz-xmaster commented 4 years ago

Hi, @zehuichen123, I have also run into the exactly same problem and tried the fix given by @PanJianning, but it seems that the fix doesn't work. Have you solved the problem? Thank you.

hyz-xmaster commented 4 years ago

Hi, @zehuichen123, I have also run into the exactly same problem and tried the fix given by @PanJianning, but it seems that the fix doesn't work. Have you solved the problem? Thank you.

One possible solution would be to change sp = self.convs[0](spx[0]) into sp = self.convs[0](spx[0].contiguous()) and change sp = self.convs[i](sp) into sp = self.convs[i](sp.contiguous())

shinya7y commented 4 years ago

I met this problem also with DCNv1. @hyz-xmaster's solution fixed both DCN version on my environment, so I sent PR.