kuangliu / pytorch-retinanet

RetinaNet in PyTorch
992 stars 250 forks source link

Specify retain_graph=True when calling backward the first time #38

Open PapaMadeleine2022 opened 6 years ago

PapaMadeleine2022 commented 6 years ago

hello, when I run retinanet.py, it shows error: Traceback (most recent call last): File "retinanet.py", line 58, in <module> test() File "retinanet.py", line 56, in test cls_preds.backward(cls_grads) File "/home/ztgong/local/anaconda2/lib/python2.7/site-packages/torch/tensor.py", line 93, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "/home/ztgong/local/anaconda2/lib/python2.7/site-packages/torch/autograd/__init__.py", line 89, in backward allow_unreachable=True) # allow_unreachable flag RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time. how to fix it? can you give some advises? thankyou

stillwaterman commented 5 years ago

maybe this discuss can help you. https://discuss.pytorch.org/t/runtimeerror-trying-to-backward-through-the-graph-a-second-time-but-the-buffers-have-already-been-freed-specify-retain-graph-true-when-calling-backward-the-first-time/6795