uoip / SSD-variants

PyTorch implementation of several SSD based object detection algorithms.
MIT License
240 stars 56 forks source link

Encounter the RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation #7

Closed yosunpeng closed 5 years ago

yosunpeng commented 5 years ago

One RuntimeError occurred when I tried to train SSD on VOC dataset. You may find more reference from Pytorch Forum: https://discuss.pytorch.org/t/encounter-the-runtimeerror-one-of-the-variables-needed-for-gradient-computation-has-been-modified-by-an-inplace-operation/836 In my case, I changed the x variable in SSD.py and it worked for me. Hope helps for you! Line 25 in model/SSD.py x /= (x.pow(2).sum(dim=1, keepdim=True).sqrt() + 1e-10) to x /= (x.clone().pow(2).sum(dim=1, keepdim=True).sqrt() + 1e-10) You may face same issue when implement other model like SSD512, you can debug by your self with detection feature in pytorch. Change codes in train.py: Line 268 in train.py train() to with torch.autograd.set_detect_anomaly(True): train() for more information: https://github.com/pytorch/pytorch/issues/15803

yosunpeng commented 5 years ago

SORRY! NOT noted there is already a same issue :3