Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torch source change: repo incompatible with versions 0.5.0 and 1.0.0 #3

Open
philipclaesson opened this issue Dec 9, 2018 · 6 comments

Comments

@philipclaesson
Copy link

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'
@sjtubblythe
Copy link

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

@snorlaxse
Copy link

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?

@sunyiyou
Copy link
Collaborator

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.

@cyizhuo
Copy link

cyizhuo commented Apr 26, 2020

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).

@AwesomeLemon
Copy link

@cyizhuo that worked perfectly, thank you so much!

@cyizhuo
Copy link

cyizhuo commented Oct 5, 2020

@cyizhuo that worked perfectly, thank you so much!

Glad to know that~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants