The root cause is likely that the code in master is after the big Tensor/Variable merge while you are using a version that doesn’t have it. The most straightforward way of dealing with this is upgrading your PyTorch version. It’s good for you!
If you don’t want to do that, you can sprinkle .data and Variable appropriately. But honestly, I think it is a dead end.
Note that the code in master had a fix for a memory leak applied today (Issue #7261), so you probably want to have that, too.
Best regards
Thomas