ScanSSD icon indicating copy to clipboard operation
ScanSSD copied to clipboard

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)

Open ES95 opened this issue 5 years ago • 7 comments

  • 760 - 07-May-20 19:39:01 - Finished loading model!
  • 760 - 07-May-20 19:39:02 - Test dataset size is 3162
  • 760 - 07-May-20 19:39:03 - processing 8/3162
  • 760 - 07-May-20 19:39:06 - Exception occurred
  • Traceback (most recent call last):
  • File "test.py", line 196, in
  • test_gtdb(args)
    
  • File "test.py", line 128, in test_gtdb
  • thresh=args.visual_threshold)
    
  • File "test.py", line 54, in test_net_batch
  • y, debug_boxes, debug_scores = net(images)  # forward pass
    
  • File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 550, in call
  • result = self.forward(*input, **kwargs)
    
  • File "/usr/local/lib/python3.6/dist-packages/torch/nn/parallel/data_parallel.py", line 153, in forward
  • return self.module(*inputs[0], **kwargs[0])
    
  • File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 550, in call
  • result = self.forward(*input, **kwargs)
    
  • File "/content/gdrive/My Drive/ssd/ScanSSD/ssd.py", line 112, in forward
  • self.priors.type(type(x.data))                  # default boxes
    
  • File "/usr/local/lib/python3.6/dist-packages/torch/autograd/function.py", line 145, 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)_
  • 760 - 07-May-20 19:39:06 - Toal time taken 0:00:08.179874
  • 760 - 07-May-20 19:39:06 - Testing done!

and i am just using two pages from pdf in gtdb dataset, is this correct "Test dataset size is 3162"

ES95 avatar May 07 '20 19:05 ES95

and i am just using two pages from pdf in gtdb dataset, is this correct "Test dataset size is 3162"

ES95 avatar May 07 '20 19:05 ES95

Yes. We generate page image crops using sliding windows.

MaliParag avatar May 07 '20 19:05 MaliParag

And what about the compatibility issue RuntimeError: Legacy autograd function with non-static forward method is deprecated. Please use new-style autograd function with static forward method

ES95 avatar May 07 '20 20:05 ES95

Are you using the pytorch and cuda version mentioned in the readme introduction?

MaliParag avatar May 07 '20 20:05 MaliParag

nope, i was running this code in colab and they don't have an option to downgrade/uninstall CUDA drivers. if you know a fix , do let me know

ES95 avatar May 07 '20 20:05 ES95

This Runtime Error is something implemented in more recent versions of Pytorch. See this Pytorch discussion forum thread for more context.

Basically the layers/detection.py needs a @staticmethod decorator on its forward method. see this GitHub repo for making the necessary updates to the code.

happy to make a merge request here if needed

jeannefukumaru avatar Aug 18 '20 09:08 jeannefukumaru

Use python 3.6 and an older version of pytorch. conda install pytorch==1.2.0 torchvision==0.4.0 -c pytorch

siriasadeddin avatar Dec 06 '22 02:12 siriasadeddin