lessw2020/Ranger21

torch.grad removed in PyTorch 1.8.1?

jszym opened this issue · 2 comments

jszym commented

I'm getting the following error with PyTorch 1.8.1

AttributeError: module 'torch' has no attribute 'grad'

Swapping Line 515 for with torch.enable_grad(): seems to resolve the error.

I can't find it in the 1.8 release notes, but it appears torch.grad() might be deprecated? Not sure if anyone else can replicate.

Cheers!

Hi @jszym - thanks for the update!
I'm literally upgrading to Pytorch 1.8 as I type...so will see if this is indeed the issue and update if so, though this sounds like a bit of an annoyance to have to check on which version of torch to then determine how to enable grad exactly.
anyway, will find out once I upgrade.
Leaving this open until I can resolve, thanks again for pointing it out!

ok I also repro this issue with 1.8.1.
In reviewing the torch docs, enable_grad() seems the correct counterpart to the @torch.no_grad() that is used in the overall step function.
I've updated and checked in.
Thanks @jszym for flagging this issue!