microsoft / nni

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
https://nni.readthedocs.io
MIT License
13.88k stars 1.81k forks source link

QuickStart example for pruning is not working properly !! #5768

Open hamdy-cryptic opened 3 months ago

hamdy-cryptic commented 3 months ago

Describe the bug: QuickStart Example provides Error at model SpeedUp. AttributeError: 'NoneType' object has no attribute 'startswith'. I tried running the pruning example quick start code and all worked fine until the section of model speedup.

Environment:

Reproduce the problem

ModelSpeedup(model, torch.rand(3, 1, 28, 28).to(device), masks).speedup_model()

2 frames /usr/local/lib/python3.10/dist-packages/nni/common/concrete_trace_utils/concrete_tracer.py in trace(self, root, autowrap_modules, autowrap_leaf_function, autowrap_leaf_class, leaf_module, fake_middle_class, concrete_args, use_operator_patch, operator_patch_backlist, forward_function_name) 956 elif func.name != func.qualname and func.qualname != 'booleandispatch..fn': 957 # method --> 958 if func.module.startswith('') and func.module != 'main': 959 path = sys.modules[func.module[1:]] 960 else:

AttributeError: 'NoneType' object has no attribute 'startswith'

BitCircuit commented 2 months ago

Same problem here

EzcodingSen commented 2 months ago

same

LongBaoCoder2 commented 2 months ago

using pytorch version 2.1. it works for me

yating-zh commented 2 months ago

!pip install torch torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda==12.1 Downgrade the Python version to 2.1.0; it works.