open-mmlab / mmdeploy

OpenMMLab Model Deployment Framework
https://mmdeploy.readthedocs.io/en/latest/
Apache License 2.0
2.78k stars 636 forks source link

[Bug] LiteHRNet Quantization Error #1991

Closed moonsh closed 1 year ago

moonsh commented 1 year ago

Checklist

Describe the bug

The below command I tried for generating INT8 litehrnet model.

python tools/deploy.py configs/mmpose/pose-detection_ncnn-int8_static-256x192.py ../mmpose/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_litehrnet-18_8xb64-210e_coco-256x192.py ../mmpose/litehrnet18_coco_256x192.pth demo/resources/human-pose.jpg --work-dir litehrnet_ncnn --device cpu --dump-info --quant --quant-image-dir imagenet-sample-images/

However, it keeps failing when it's generating a quant table. and error message is below

AttributeError: 'ConfigDict' object has no attribute '_env_variables' mmengine - ERROR - tools/deploy.py - create_process - 82 - ncnn quant table failed.

Reproduction

python tools/deploy.py configs/mmpose/pose-detection_ncnn-int8_static-256x192.py ../mmpose/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_litehrnet-18_8xb64-210e_coco-256x192.py ../mmpose/litehrnet18_coco_256x192.pth demo/resources/human-pose.jpg --work-dir litehrnet_ncnn --device cpu --dump-info --quant --quant-image-dir imagenet-sample-images/

Environment

04/14 08:15:09 - mmengine - INFO - **********Environmental information**********
04/14 08:15:10 - mmengine - INFO - sys.platform: linux
04/14 08:15:10 - mmengine - INFO - Python: 3.8.16 (default, Mar  2 2023, 03:21:46) [GCC 11.2.0]
04/14 08:15:10 - mmengine - INFO - CUDA available: True
04/14 08:15:10 - mmengine - INFO - numpy_random_seed: 2147483648
04/14 08:15:10 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 3090 Ti
04/14 08:15:10 - mmengine - INFO - CUDA_HOME: /usr
04/14 08:15:10 - mmengine - INFO - NVCC: Cuda compilation tools, release 10.1, V10.1.24
04/14 08:15:10 - mmengine - INFO - GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
04/14 08:15:10 - mmengine - INFO - PyTorch: 1.12.1+cu113
04/14 08:15:10 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.3
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86
  - CuDNN 8.3.2  (built against CUDA 11.5)
  - Magma 2.5.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.3.2, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.12.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=OFF, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

04/14 08:15:10 - mmengine - INFO - TorchVision: 0.13.1+cu113
04/14 08:15:10 - mmengine - INFO - OpenCV: 4.7.0
04/14 08:15:10 - mmengine - INFO - MMEngine: 0.7.1
04/14 08:15:10 - mmengine - INFO - MMCV: 2.0.0
04/14 08:15:10 - mmengine - INFO - MMCV Compiler: GCC 9.3
04/14 08:15:10 - mmengine - INFO - MMCV CUDA Compiler: 11.3
04/14 08:15:10 - mmengine - INFO - MMDeploy: 1.0.0rc3+0196cd0
04/14 08:15:10 - mmengine - INFO - 

04/14 08:15:10 - mmengine - INFO - **********Backend information**********
04/14 08:15:10 - mmengine - INFO - tensorrt:    None
04/14 08:15:10 - mmengine - INFO - ONNXRuntime: 1.14.1
04/14 08:15:10 - mmengine - INFO - ONNXRuntime-gpu: None
04/14 08:15:10 - mmengine - INFO - ONNXRuntime custom ops:  NotAvailable
04/14 08:15:10 - mmengine - INFO - pplnn:   None
04/14 08:15:10 - mmengine - INFO - ncnn:    1.0.20230414
04/14 08:15:10 - mmengine - INFO - ncnn custom ops: Available
04/14 08:15:10 - mmengine - INFO - snpe:    None
04/14 08:15:10 - mmengine - INFO - openvino:    None
04/14 08:15:10 - mmengine - INFO - torchscript: 1.12.1+cu113
04/14 08:15:10 - mmengine - INFO - torchscript custom ops:  NotAvailable
04/14 08:15:10 - mmengine - INFO - rknn-toolkit:    None
04/14 08:15:10 - mmengine - INFO - rknn-toolkit2:   None
04/14 08:15:10 - mmengine - INFO - ascend:  None
04/14 08:15:10 - mmengine - INFO - coreml:  None
04/14 08:15:10 - mmengine - INFO - tvm: None
04/14 08:15:10 - mmengine - INFO - vacc:    None
04/14 08:15:10 - mmengine - INFO - 

04/14 08:15:10 - mmengine - INFO - **********Codebase information**********
04/14 08:15:10 - mmengine - INFO - mmdet:   3.0.0
04/14 08:15:10 - mmengine - INFO - mmseg:   None
04/14 08:15:10 - mmengine - INFO - mmcls:   None
04/14 08:15:10 - mmengine - INFO - mmocr:   None
04/14 08:15:10 - mmengine - INFO - mmedit:  None
04/14 08:15:10 - mmengine - INFO - mmdet3d: None
04/14 08:15:10 - mmengine - INFO - mmpose:  1.0.0
04/14 08:15:10 - mmengine - INFO - mmrotate:    None
04/14 08:15:10 - mmengine - INFO - mmaction:    None
04/14 08:15:10 - mmengine - INFO - mmrazor: None

Error traceback

No response

irexyc commented 1 year ago

Hi, @moonsh

Sorry for late reply, I have fixed the dataloader for ncnn quantization, you can apply the code change according to https://github.com/open-mmlab/mmdeploy/pull/2018

moonsh commented 1 year ago

@irexyc No problem!. Thank you for the update!