epic-kitchens/epic-kitchens-55-action-models

PyTorch 1.5 compatibility

Closed this issue · 1 comments

Running tests/test_checkpoints.py produces the following stack traces under PT 1.5

___________________________________________________________ test_demo[args16] ___________________________________________________________

args = ['tsn', '--tsn-consensus-type=max']

@pytest.mark.parametrize("args", example_cli_args)
def test_demo(args: List[str]):
>       demo.main(demo.parser.parse_args(args))

tests/test_checkpoints.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
demo.py:135: in main
output = model(input)
../.miniconda3/envs/epic-action-models/lib/python3.7/site-packages/torch/nn/modules/module.py:550: in __call__
result = self.forward(*input, **kwargs)
tsn.py:442: in forward
return self.logits(features)
tsn.py:416: in logits
output_verb = self.consensus(logits_verb)
../.miniconda3/envs/epic-action-models/lib/python3.7/site-packages/torch/nn/modules/module.py:550: in __call__
result = self.forward(*input, **kwargs)
ops/basic_ops.py:46: in forward
return SegmentConsensus(self.consensus_type, self.dim)(input)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ops.basic_ops.SegmentConsensus object at 0x7f90019447d0>
args = (tensor([[[-0.0125,  0.0014,  0.1074, -0.0365, -0.0816,  0.0358,  0.0590,
0.0926, -0.0277,  0.0524,  0.0169..., -0.0461,  0.0107,
0.0453,  0.0764, -0.0235,  0.0126, -0.0139, -0.0625]]],
grad_fn=<ViewBackward>),)
kwargs = {}

def __call__(self, *args, **kwargs):
raise 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)")
E       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)

../.miniconda3/envs/epic-action-models/lib/python3.7/site-packages/torch/autograd/function.py:145: RuntimeError
--------------------------------------------------------- Captured stdo

Basically we need to update the consensus function/strip it out to work with the new style autograd functions in PT1.5:

In previous versions of PyTorch, there were two ways to write autograd Functions. We deprecated one of them in 1.3.0 and dropped support for it entirely in 1.5.0. Old-style autograd Functions will no longer work in user code.

These Functions be identified by not having staticmethod forward and backward functions (see the example below) Please see the current documentation for how to write new-style Functions.
-- https://github.com/pytorch/pytorch/releases/tag/v1.5.0

Fixed in 339bf1f