Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running Inference: forward call is outdated and returns an error when called. #268

Open
onurbagoren opened this issue Mar 17, 2022 · 0 comments

Comments

@onurbagoren
Copy link

Hello,
I am attempting to run the inference using the model. I run the provided command of

$ python3 main.py --inference --model FlowNet2 --save_flow --inference_dataset MpiSintelClean \
 --inference_dataset_root $INFERENCE_DATASET --resume $CHECKPOINTS_DIR

I get an error at line 374 of main.py

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)

I followed the instructions from the provided link and added @staticmethod to the forward function. I now get a new error regarding the number of parameters in the model(data[0], target[0], inference=True) call at line 374 of main.py.

I tried several solutions:

  1. Explicitly call `model.forward(data[0], target[0], inference=True)
    This did not work and returned the error:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/$HOME/.local/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/home/$HOME/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() missing 1 required positional argument: 'target'
  1. I then tried to name the parameters that are defined in the forward call from the model ModelAndLoss like so: model.forward(data=data[0], target=target[0], inference=True)
    I then received the following error:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/$HOME/.local/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/home/$HOME/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() missing 1 required positional argument: 'self'

This implies that the object call to its own instance is required somehow in order to make this a valid call, so I tried:
3. model.forward(self=model, data=data[0], target=target[0], inference=True) and this then returned the error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: forward() got multiple values for argument 'self'

I am at a lost of ideas, any recommendations on how to fix this would be greatly appreciated.

To add some more references, I used the changes made in the pull request in #254 in order to install the custom layers, as my compiler is c++14.

Besides this, I have not made any other changes. Any maintainers help would be greatly appreciated!!

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant