arunmallya / packnet

Code for PackNet: Adding Multiple Tasks to a Single Network by Iterative Pruning
https://arxiv.org/abs/1711.05769
229 stars 40 forks source link

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

Closed MrLinNing closed 6 years ago

MrLinNing commented 6 years ago

hello,

I run this command:

python main.py --mode eval --dataset cubs_cropped \
  --loadname ../checkpoints/csf_0.75,0.75,-1_vgg16_0.5-nobias-nobn_1.pt

everything is ok, but test other model,

python main.py --mode eval --dataset cubs_cropped \
  --loadname ../checkpoints/csf_0.75,0.75,-1_vgg16bn_0.5-nobias-nobn_1.pt

or

python main.py --mode eval --dataset cubs_cropped \
  --loadname ../checkpoints/csf_0.75,0.75,-1_densenet121_0.5-nobias-nobn_1.pt

problem happened.

result = self.forward(*input, **kwargs)
File "pytorch_test/ijcai/packnet/src/networks.py", line 78, in forward
     x = self.shared(x)
File "pytorch_test/env3/lib/python3.5/site-packages/torch/nn/modules/module.py",
    result = self.forward(*input, **kwargs)
File "/home/linning/pytorch_test/env3/lib/python3.5/site-packages/torch/nn/modules/batchnorm.py", line 49, 
     self.training or not self.track_running_stats, self.momentum, self.eps)
AttributeError: 'BatchNorm2d' object has no attribute 'track_running_stats'

My PyTorch version is : 0.4.0, python version is 3.5 Could you help me fixed it, thank you! @arunmallya

arunmallya commented 6 years ago

I'm sorry, I have updated the README to note that torch==0.2.0.post3 is required. This code might not be compatible with the newer pytorch versions due to api changes. You can find older versions here: https://pytorch.org/get-started/previous-versions/ Hope this helps you.

MrLinNing commented 6 years ago

Thank you very much! So, I could train the script using your code. By the way, how to use Muti-GPUS training the imagenet model? I found that training with a single GPU is very slow.

~/packnet/src$ ./scripts/run_imagenet_pruning.sh  vgg16 0.5 1

I modified the main.py in 203 line, image And modified the run_imagenet_pruning.sh image But it couldn't run on 4 GPUs. @arunmallya

arunmallya commented 6 years ago

I believe the modification to the backward pass might cause issues with multi-gpu training. Will have to go through the docs and figure out how exactly things work in that case. It might be best to stick with a single GPU until then.

Breezeqiuyu commented 5 years ago

Thank you very much! So, I could train the script using your code. By the way, how to use Muti-GPUS training the imagenet model? I found that training with a single GPU is very slow.

~/packnet/src$ ./scripts/run_imagenet_pruning.sh  vgg16 0.5 1

I modified the main.py in 203 line, image And modified the run_imagenet_pruning.sh image But it couldn't run on 4 GPUs. @arunmallya

Hi, I want to know if you need to use imagenet data set when pruning the VGG network trained in imagenet, so which version of imagenet is used? Can you send a link? thank you!

spongiaaa commented 1 year ago

Thank you very much! So, I could train the script using your code. By the way, how to use Muti-GPUS training the imagenet model? I found that training with a single GPU is very slow.

~/packnet/src$ ./scripts/run_imagenet_pruning.sh  vgg16 0.5 1

I modified the main.py in 203 line, image And modified the run_imagenet_pruning.sh image But it couldn't run on 4 GPUs. @arunmallya

Hi, I want to know if you need to use imagenet data set when pruning the VGG network trained in imagenet, so which version of imagenet is used? Can you send a link? thank you!

@Breezeqiuyu Do you solved the dataset problem? I have the same question as yours.