Which pytorch version do I need?

I am trying to run the code for Fader Networks, available here. But whichever version of pytorch I use I get attribute errors.

When I try version 0.3.0 I get this attribute error:

AttributeError: Can't get attribute '_rebuild_tensor_v2' on <module 'torch._utils'>

When I try 0.4 or higher I get a different attribute error:

AttributeError: 'BatchNorm2d' object has no attribute 'track_running_stats'

My question is which version of pytorch had both torch._utils._rebuild_rensor_v2 and BatchNorm2d.track_running_stats.

PS I have left an issue on the project’s github repo, but repo seems inactive so I don’t expect a response there.

How about taking the middle road? Did you try 0.3.1? Got it from here.

You may also try writing to the authors whose e-mail addresses are in the article (link in github).

Yeah, I did also try 0.3.1, with no luck. I could try the email from the paper, but I’m doubtful that I’ll get a response regarding a 2/3 yo paper so I thought I’d ask the community first.

1 Like

UPDATE: While I’ve not exactly found the solution, I think I have found the cause of the issue. I was in effect trying to load pre-trained models and apply them. These models must’ve been trained with an older version of pytorch, where BatchNorm2d did not have (and hence did not save) the ‘track_running_stats’ attribute.

The confusing thing is that using an older version of pytorch failed due to a reliance on the ‘_rebuild_tensor_v2’ attribute of torch._utils, which seemingly references a pytorch version later than that used to train the example models.

My only explanation is that the models available were saved with an older version of pytorch, development was then made with a newer version of pytorch, and backwards compatibility with available pre-trained models was not checked.

The fix for me is hopefully just to re-train all models from scratch using a new version of pytorch, so that my own saved models will have BatchNorm2d objects with the track_runnning_stats attributes (c.f. https://github.com/xingyizhou/pytorch-pose-hg-3d/issues/36).


1 Like