How to perform qat quantization for secondary classification of deepstream 7.0, pytorch-quantization has problems!
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 13.4k
- Forks
- 2.4k
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 2
Description
I want to use pytorch-quantization to perform classification quantization of Deepstream7, which can be done normally in deepstream6. The process is to use torch-tensorrt==1.4.0 and pytorch-quantization==2.1.3, then export to jit file, and export to int8 quantization result of trt.
This step now encounters a problem. Its trt file has an error in the secondary classification of deepstream:
ERROR: [TRT]: 1: [runtime.cpp::parsePlan::314] Error Code 1: Serialization (Serialization assertion plan->header.magicTag == rt::kPLAN_MAGIC_TAG failed.)
ERROR: ../nvdsinfer/nvdsinfer_model_builder.cpp:1540 Deserialize engine failed from file: /root/ai/weights/convnext_tiny.in12k_ft_in1k_bird2683_16_int8.trt
0:00:09.422453039 587 0x5bf6fbc35240 WARN nvinfer gstnvinfer.cpp:679:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 5]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:2083> [UID = 5]: deserialize engine from file :/root/ai/weights/convnext_tiny.in12k_ft_in1k_bird2683_16_int8.trt failed
0:00:09.616871719 587 0x5bf6fbc35240 WARN nvinfer gstnvinfer.cpp:679:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 5]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2188> [UID = 5]: deserialize backend context from engine from file :/root/ai/weights/convnext_tiny.in12k_ft_in1k_bird2683_16_int8.trt failed, try rebuild
0:00:09.616900305 587 0x5bf6fbc35240 INFO nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 5]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2109> [UID = 5]: Trying to create engine from model files
ERROR: ../nvdsinfer/nvdsinfer_model_builder.cpp:870 failed to build network since there is no model file matched.
ERROR: ../nvdsinfer/nvdsinfer_model_builder.cpp:809 failed to build network.
0:00:17.749614745 587 0x5bf6fbc35240 ERROR nvinfer gstnvinfer.cpp:676:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 5]: Error in NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:2129> [UID = 5]: build engine file failed
0:00:17.950502275 587 0x5bf6fbc35240 ERROR nvinfer gstnvinfer.cpp:676:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 5]: Error in NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2215> [UID = 5]: build backend context failed
0:00:17.950534728 587 0x5bf6fbc35240 ERROR nvinfer gstnvinfer.cpp:676:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 5]: Error in NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1352> [UID = 5]: generate backend failed, check config file settings
0:00:17.950601441 587 0x5bf6fbc35240 WARN nvinfer gstnvinfer.cpp:912:gst_nvinfer_start:<secondary_gie_0> error: Failed to create NvDsInferContext instance
0:00:17.950608794 587 0x5bf6fbc35240 WARN nvinfer gstnvinfer.cpp:912:gst_nvinfer_start:<secondary_gie_0> error: Config file path: /root/ai/incarai2024/configs/config_infer_secondary_bird.txt, NvDsInfer Error: NVDSINFER_CONFIG_FAILED
** ERROR: <init_deep_stream:1699>: Failed to set pipeline to PAUSED
I tried to upgrade pytorch-quantization==2.2.1, but the problem became even bigger. I couldn't find the corresponding pytorch version and pytorch_tensorrt version. What should I do?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the DeepStream 7.0 secondary-classifier load using torch-tensorrt==1.4.0 and pytorch-quantization==2.1.3, then compare with 2.2.1 and record compatible PyTorch versions. Check the generated .trt file and configs/config_infer_secondary_bird.txt; done means a valid INT8 engine deserializes and the secondary classifier initializes without the shown errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pytorch
- Domain
- machine-learning, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100