NetDissect-Lite icon indicating copy to clipboard operation
NetDissect-Lite copied to clipboard

Torch source change: repo incompatible with versions 0.5.0 and 1.0.0

Open philipclaesson opened this issue 6 years ago • 6 comments

It seems the repo is suffering from changes in Torch source code, more specifically in the use of the BatchNorm2d object put possibly on more places.

The repo works fine for the resnet18 model, but downloading and using the pretrained models for resnet50 and densenet161 yields errors:

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

There are also a set of SourceChangeWarnings, among other:

/jet/var/python/lib/python3.6/site-packages/torch/serialization.py:425: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. 
you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the chang
es.

Tried running both Pytorch versions 0.5.0 and 1.0.0. This thread suggests downgrading Pytorch to 0.3 would make it work, will update if I get the possibility to do so.

Error Log

Traceback (most recent call last):
  File "main.py", line 11, in <module>
    features, maxfeature = fo.feature_extraction(model=model)
  File "/jet/prs/NetDissect-Lite/feature_operation.py", line 67, in feature_extraction
    logit = model.forward(input_var)
  File "/jet/var/python/lib/python3.6/site-packages/torchvision/models/densenet.py", line 157, in forward
    features = self.features(x)
  File "/jet/var/python/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/jet/var/python/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
    input = module(input)
  File "/jet/var/python/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/jet/var/python/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 65, in forward
    self.training or not self.track_running_stats,
  File "/jet/var/python/lib/python3.6/site-packages/torch/nn/modules/module.py", line 518, in __getattr__
    type(self).__name__, name))
AttributeError: 'BatchNorm2d' object has no attribute 'track_running_stats'

philipclaesson avatar Dec 09 '18 15:12 philipclaesson

I had same issue. Downgrading torch to 0.3.1 works for me.

sjtubblythe avatar Jan 15 '19 19:01 sjtubblythe

I had same issue. Downgrading torch to 0.3.1 works for me.

After Downgrading torch to 0.3.1, and run the 'main.py' .

RuntimeError: CUDNN_STATUS_EXECUTION_FAILED

How to solve?

snorlaxse avatar Apr 22 '19 06:04 snorlaxse

I had same issue. Downgrading torch to 0.3.1 works for me.

After Downgrading torch to 0.3.1, and run the 'main.py' .

RuntimeError: CUDNN_STATUS_EXECUTION_FAILED

How to solve?

This is mostly like an issue of your CUDA. For example, if you are using 2080Ti and CUDA10, pytorch 0.3 is not supportive enough. Since it is an 'old' repo, you might have to try the 'old' settings like 1080Ti and CUDA8 where the environment is fully tested.

sunyiyou avatar Apr 25 '19 21:04 sunyiyou

Don't know if it helps or not, but I created conda env with:

conda install scipy==1.0.0 (must be installed first) conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

and Net-Dissection-Lite worked perfect (on linux, never successed on windows).

cyizhuo avatar Apr 26 '20 12:04 cyizhuo

@cyizhuo that worked perfectly, thank you so much!

AwesomeLemon avatar Oct 05 '20 09:10 AwesomeLemon

@cyizhuo that worked perfectly, thank you so much!

Glad to know that~

cyizhuo avatar Oct 05 '20 10:10 cyizhuo