amdegroot / ssd.pytorch

A PyTorch Implementation of Single Shot MultiBox Detector
MIT License
5.15k stars 1.75k forks source link

RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method. #554

Closed cnr0724 closed 3 years ago

cnr0724 commented 3 years ago
/home/dnaplus/Downloads/ssd.pytorch/ssd.py:34: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  self.priors = Variable(self.priorbox.forward(), volatile=True)
Finished loading model!
Traceback (most recent call last):
  File "eval.py", line 438, in <module>
    thresh=args.confidence_threshold)
  File "eval.py", line 385, in test_net
    detections = net(x).data
  File "/home/dnaplus/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/dnaplus/Downloads/ssd.pytorch/ssd.py", line 103, in forward
    self.priors.type(type(x.data))                  # default boxes
  File "/home/dnaplus/.local/lib/python3.6/site-packages/torch/autograd/function.py", line 160, in __call__
    "Legacy autograd function with non-static forward method is deprecated. "
RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method. (Example: https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function)

What should I do when this happens while using eval.py? Just downgrade the torch version?

cnr0724 commented 3 years ago

444 This helped me solving the problem.