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.98k stars 1.81k forks source link

Error runing quantization_speedup.py #5002

Open Raychen0617 opened 2 years ago

Raychen0617 commented 2 years ago

Describe the issue: When running quantization_speedup.py in the tutorial file (I did not change anything), I got an error as below.

[2022-07-20 01:41:46] Model state_dict saved to ./log/mnist_model.pth
[2022-07-20 01:41:46] Mask dict saved to ./log/mnist_calibration.pth
[07/20/2022-01:41:49] [TRT] [W] DynamicRange(min: -0.424213, max: 2.82149). Dynamic range should be symmetric for better accuracy.
Traceback (most recent call last):
  File "quantization_speedup.py", line 114, in <module>
    engine.compress()
  File "/opt/conda/lib/python3.7/site-packages/nni/compression/pytorch/quantization_speedup/integrated_tensorrt.py", line 298, in compress
    context = self._tensorrt_build_withoutcalib(self.onnx_path)
  File "/opt/conda/lib/python3.7/site-packages/nni/compression/pytorch/quantization_speedup/integrated_tensorrt.py", line 348, in _tensorrt_build_withoutcalib
    engine = build_engine(onnx_path, self.onnx_config, self.extra_layer_bits, self.strict_datatype)
  File "/opt/conda/lib/python3.7/site-packages/nni/compression/pytorch/quantization_speedup/integrated_tensorrt.py", line 198, in build_engine
    handle_gemm(network, i, config)
  File "/opt/conda/lib/python3.7/site-packages/nni/compression/pytorch/quantization_speedup/integrated_tensorrt.py", line 82, in handle_gemm
    pre_in_tensor.dynamic_range = (tracked_min_input, tracked_max_input)
AttributeError: 'NoneType' object has no attribute 'dynamic_range'

Environment:

Configuration:

Log message:

How to reproduce it?:

QuanluZhang commented 2 years ago

@Raychen0617 , thanks for reporting this issue, which tutorial did you run?

Raychen0617 commented 2 years ago

This one https://github.com/microsoft/nni/blob/e8c78bbab03fa651563e21cdf004220f29d9560a/examples/tutorials/quantization_speedup.py