open-mmlab / mmdeploy

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

[Bug] ERROR - create_process - 82 - visualize ncnn model failed. #2661

Closed 360Ibra closed 9 months ago

360Ibra commented 9 months ago

Checklist

Describe the bug

I'm encountering a ValueError during the deployment process of my RTMPOSE model on GitHub. The error message specifically mentions 'not enough values to unpack (expected 2, got 1).' Despite searching for similar issues, I haven't found a solution. I would greatly appreciate assistance from anyone who can help me resolve this issue.

Reproduction

python ./tools/deploy.py \ /home/ibrahim/mmdeploy/configs/mmpose/pose-detection_ncnn_static-256x192.py \ /home/ibrahim/mmpose/work_dirs/rtmpose-t_8xb256-420e_coco-256x192/rtmpose-t_8xb256-420e_coco-256x192.py \ /home/ibrahim/mmpose/work_dirs/rtmpose-t_8xb256-420e_coco-256x192/epoch_1_publish-de0cee58_20240126.pth \ /home/ibrahim/Pictures/demo.jpg \ --test-img /home/ibrahim/Pictures/demo.jpg \ --work-dir /home/ibrahim/mmpose/work_dirs \ --device cuda:0 \ --log-level INFO \ --show \ --dump-info

Environment

01/26 20:04:04 - mmengine - INFO - 

01/26 20:04:04 - mmengine - INFO - **********Environmental information**********
01/26 20:04:05 - mmengine - INFO - sys.platform: linux
01/26 20:04:05 - mmengine - INFO - Python: 3.8.18 (default, Sep 11 2023, 13:40:15) [GCC 11.2.0]
01/26 20:04:05 - mmengine - INFO - CUDA available: True
01/26 20:04:05 - mmengine - INFO - MUSA available: False
01/26 20:04:05 - mmengine - INFO - numpy_random_seed: 2147483648
01/26 20:04:05 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 3060 Ti
01/26 20:04:05 - mmengine - INFO - CUDA_HOME: None
01/26 20:04:05 - mmengine - INFO - GCC: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
01/26 20:04:05 - mmengine - INFO - PyTorch: 2.1.2
01/26 20:04:05 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201703
  - Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v3.1.1 (Git Hash 64f6bcbcbab628e96f33a62c3e975f8535a7bde4)
  - 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.8
  - NVCC architecture flags: -gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-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;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_90,code=sm_90;-gencode;arch=compute_37,code=compute_37
  - CuDNN 8.7
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -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_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.1.2, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

01/26 20:04:05 - mmengine - INFO - TorchVision: 0.16.2
01/26 20:04:05 - mmengine - INFO - OpenCV: 4.9.0
01/26 20:04:05 - mmengine - INFO - MMEngine: 0.10.3
01/26 20:04:05 - mmengine - INFO - MMCV: 2.1.0
01/26 20:04:05 - mmengine - INFO - MMCV Compiler: GCC 9.3
01/26 20:04:05 - mmengine - INFO - MMCV CUDA Compiler: 11.8
01/26 20:04:05 - mmengine - INFO - MMDeploy: 1.3.1+bc75c9d
01/26 20:04:05 - mmengine - INFO - 

01/26 20:04:05 - mmengine - INFO - **********Backend information**********
01/26 20:04:05 - mmengine - INFO - tensorrt:    None
01/26 20:04:05 - mmengine - INFO - ONNXRuntime: 1.8.1
01/26 20:04:05 - mmengine - INFO - ONNXRuntime-gpu:     1.8.1
01/26 20:04:05 - mmengine - INFO - ONNXRuntime custom ops:      NotAvailable
01/26 20:04:05 - mmengine - INFO - pplnn:       None
01/26 20:04:05 - mmengine - INFO - ncnn:        1.0.20240126
01/26 20:04:05 - mmengine - INFO - ncnn custom ops:     Available
01/26 20:04:05 - mmengine - INFO - snpe:        None
01/26 20:04:05 - mmengine - INFO - openvino:    None
01/26 20:04:05 - mmengine - INFO - torchscript: 2.1.2
01/26 20:04:05 - mmengine - INFO - torchscript custom ops:      NotAvailable
01/26 20:04:05 - mmengine - INFO - rknn-toolkit:        None
01/26 20:04:05 - mmengine - INFO - rknn-toolkit2:       None
01/26 20:04:05 - mmengine - INFO - ascend:      None
01/26 20:04:05 - mmengine - INFO - coreml:      None
01/26 20:04:05 - mmengine - INFO - tvm: None
01/26 20:04:05 - mmengine - INFO - vacc:        None
01/26 20:04:05 - mmengine - INFO - 

01/26 20:04:05 - mmengine - INFO - **********Codebase information**********
01/26 20:04:05 - mmengine - INFO - mmdet:       3.2.0
01/26 20:04:05 - mmengine - INFO - mmseg:       None
01/26 20:04:05 - mmengine - INFO - mmpretrain:  None
01/26 20:04:05 - mmengine - INFO - mmocr:       None
01/26 20:04:05 - mmengine - INFO - mmagic:      None
01/26 20:04:05 - mmengine - INFO - mmdet3d:     None
01/26 20:04:05 - mmengine - INFO - mmpose:      1.3.1
01/26 20:04:05 - mmengine - INFO - mmrotate:    None
01/26 20:04:05 - mmengine - INFO - mmaction:    None
01/26 20:04:05 - mmengine - INFO - mmrazor:     None
01/26 20:04:05 - mmengine - INFO - mmyolo:      None

Error traceback

01/26 20:00:10 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
01/26 20:00:10 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "mmpose_tasks" registry tree. As a workaround, the current "mmpose_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
01/26 20:00:12 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess
01/26 20:00:14 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
01/26 20:00:14 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "mmpose_tasks" registry tree. As a workaround, the current "mmpose_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
Loads checkpoint by local backend from path: /home/ibrahim/mmpose/work_dirs/rtmconfig/epoch_2_publish-eee7d426_20240125.pth
/home/ibrahim/mmpose/mmpose/datasets/datasets/utils.py:102: UserWarning: The metainfo config file "configs/_base_/datasets/mpii.py" does not exist. A matched config file "/home/ibrahim/mmpose/mmpose/.mim/configs/_base_/datasets/mpii.py" will be used instead.
  warnings.warn(
01/26 20:00:14 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future. 
01/26 20:00:14 - mmengine - INFO - Export PyTorch model to ONNX: /home/ibrahim/mmpose/work_dirs/end2end.onnx.
01/26 20:00:14 - mmengine - WARNING - Can not find mmdet.models.dense_heads.RPNHead.get_bboxes, function rewrite will not be applied
/home/ibrahim/mmdeploy/mmdeploy/pytorch/functions/size.py:23: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  ret = [int(r) for r in ret]
/home/ibrahim/mmdeploy/mmdeploy/pytorch/functions/getattribute.py:19: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  ret = torch.Size([int(s) for s in ret])
[W shape_type_inference.cpp:1974] Warning: The shape inference of mmdeploy::AdaptiveAvgPool2d type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
[W shape_type_inference.cpp:1974] Warning: The shape inference of mmdeploy::AdaptiveAvgPool2d type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
[W shape_type_inference.cpp:1974] Warning: The shape inference of mmdeploy::AdaptiveAvgPool2d type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
[W shape_type_inference.cpp:1974] Warning: The shape inference of mmdeploy::AdaptiveAvgPool2d type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. (function UpdateReliable)
01/26 20:00:23 - mmengine - INFO - Finish pipeline mmdeploy.apis.pytorch2onnx.torch2onnx
01/26 20:00:23 - mmengine - INFO - Start pipeline mmdeploy.apis.utils.utils.to_backend in main process
onnx2ncnn finish
01/26 20:00:24 - mmengine - INFO - Finish pipeline mmdeploy.apis.utils.utils.to_backend
01/26 20:00:24 - mmengine - INFO - visualize ncnn model start.
01/26 20:00:27 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
01/26 20:00:27 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "mmpose_tasks" registry tree. As a workaround, the current "mmpose_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
01/26 20:00:27 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "backend_segmentors" registry tree. As a workaround, the current "backend_segmentors" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
/home/ibrahim/mmpose/mmpose/datasets/datasets/utils.py:102: UserWarning: The metainfo config file "configs/_base_/datasets/mpii.py" does not exist. A matched config file "/home/ibrahim/mmpose/mmpose/.mim/configs/_base_/datasets/mpii.py" will be used instead.
  warnings.warn(
output
2024-01-26:20:00:27 - root - ERROR - not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/home/ibrahim/mmdeploy/mmdeploy/utils/utils.py", line 41, in target_wrapper
    result = target(*args, **kwargs)
  File "/home/ibrahim/mmdeploy/mmdeploy/apis/visualize.py", line 72, in visualize_model
    result = model.test_step(model_inputs)[0]
  File "/home/ibrahim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/model/base_model/base_model.py", line 145, in test_step
    return self._run_forward(data, mode='predict')  # type: ignore
  File "/home/ibrahim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/model/base_model/base_model.py", line 361, in _run_forward
    results = self(**data, mode=mode)
  File "/home/ibrahim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/ibrahim/miniconda3/envs/openmmlab/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/ibrahim/mmdeploy/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py", line 122, in forward
    batch_pred_x, batch_pred_y = batch_outputs
ValueError: not enough values to unpack (expected 2, got 1)
01/26 20:00:27 - mmengine - ERROR - ./tools/deploy.py - create_process - 82 - visualize ncnn model failed.
BingoZZBZZ commented 8 months ago

I have a same problem. have you solved that problem?

just like Traceback (most recent call last):

File "/home/zhengzb/mmdeploy/tools/deploy.py", line 335, in

main()

File "/home/zhengzb/mmdeploy/tools/deploy.py", line 259, in main

backend_files = to_backend(

File "/home/zhengzb/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap

return self.call_function(func_name_, *args, **kwargs)

File "/home/zhengzb/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function

return self.call_function_local(func_name, *args, **kwargs)

File "/home/zhengzb/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local

return pipe_caller(*args, **kwargs)

File "/home/zhengzb/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in call

ret = func(*args, **kwargs)

File "/home/zhengzb/mmdeploy/mmdeploy/apis/utils/utils.py", line 98, in to_backend

return backend_mgr.to_backend(

File "/home/zhengzb/mmdeploy/mmdeploy/backend/openvino/backend_manager.py", line 97, in to_backend

from_onnx(onnx_path, work_dir, input_info, output_names,

File "/home/zhengzb/mmdeploy/mmdeploy/backend/openvino/onnx2openvino.py", line 114, in from_onnx

mo_output = run(command, stdout=PIPE, stderr=PIPE, shell=True, check=True)

File "/home/zhengzb/download/yes/envs/mmdeploy/lib/python3.9/subprocess.py", line 528, in run

raise CalledProcessError(retcode, process.args,

subprocess.CalledProcessError: Command 'mo --input_model="rtmpose/word_dir/end2end.onnx" --output_dir="rtmpose/word_dir" --output="output" --input="input" --input_shape="[1, 3, 256, 192]" ' returned non-zero exit status 1.

360Ibra commented 8 months ago

Hey @BingoZZBZZ , Apologies for the late reply if you still haven't managed to fix it in my case it was an error on my behalf specifically when selecting the backend configuration for the model this is what fixed it for me I just changed the backend configuration to configs/mmpose/pose-detection_simcc_ncnn-fp16_static-256x192.py . When debugging the problem I was printing out the tensors and realized I was only receiving one when the expected was two so when I changed to this backend configuration it had two outputs for simcc x and y then when I tried printing again I was receiving two tensors and this solved it in my case.