Skip to content

[Bug] 转换模型直接退出程序了,能不能帮忙解决一下 #2926

Open

Description

@James-Zhangpp

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

C:\Users\ASUS\AppData\Local\Programs\Python\Python311\python.exe C:\Users\ASUS\Desktop\newPro\mmdeploy\test.py
ONNXRuntime 版本 1.16.0
Pytorch 版本 2.1.0+cu118
Pytorch 版本 0.16.0+cu118
CUDA 是否可用 True
11/18 21:16:22 - mmengine - WARNING - Failed to search registry with scope "mmseg" 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 "mmseg" is a correct scope, or whether the registry is initialized.
11/18 21:16:22 - mmengine - WARNING - Failed to search registry with scope "mmseg" in the "mmseg_tasks" registry tree. As a workaround, the current "mmseg_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmseg" is a correct scope, or whether the registry is initialized.
c:\users\asus\desktop\newpro\mmsegmentation\mmseg\models\decode_heads\decode_head.py:120: UserWarning: For binary segmentation, we suggest usingout_channels = 1 to define the outputchannels of segmentor, and use thresholdto convert seg_logits into a predictionapplying a threshold
warnings.warn('For binary segmentation, we suggest using'
c:\users\asus\desktop\newpro\mmsegmentation\mmseg\models\losses\cross_entropy_loss.py:250: UserWarning: Default avg_non_ignore is False, if you would like to ignore the certain label and average loss over non-ignore labels, which is the same with PyTorch official cross_entropy, set avg_non_ignore=True.
warnings.warn(
Loads checkpoint by local backend from path: FPCDataset-Segformer/iter_40000.pth
11/18 21:16:23 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future.
11/18 21:16:23 - mmengine - INFO - Export PyTorch model to ONNX: work_dir/end2end.onnx.
C:\Users\ASUS\Desktop\newPro\mmdeploy\mmdeploy\core\optimizers\function_marker.py:160: 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!
ys_shape = tuple(int(s) for s in ys.shape)
c:\users\asus\desktop\newpro\mmsegmentation\mmseg\models\utils\shape_convert.py:15: TracerWarning: Converting a tensor to a Python boolean 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!
assert L == H * W, 'The seq_len doesn't match H, W'
C:\Users\ASUS\Desktop\newPro\mmdeploy\mmdeploy\codebase\mmseg\models\segmentors\base.py:61: TracerWarning: Converting a tensor to a Python boolean 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!
if seg_logit.shape[1] == 1:

进程已结束,退出代码为 -1073741819 (0xC0000005)

Reproduction

import onnxruntime as ort
print('ONNXRuntime 版本', ort.version)

import torch, torchvision

print('Pytorch 版本', torch.version)
print('Pytorch 版本', torchvision.version)
print('CUDA 是否可用', torch.cuda.is_available())

#python tools/deploy.py configs/mmseg/segmentation_onnxruntime_dynamic.py FPCDataset-Segformer/FPCDataset_Segformer_20251012.py FPCDataset-Segformer/iter_40000.pth FPCDataset-Segformer/_2-1_OK_2025-10-08-16-53-02-934.png --work-dir mmseg2onnx_segformer --dump-info

#python tools/deploy.py configs/mmseg/segmentation_tensorrt-int8_static-512x512.py FPCDataset-Segformer/FPCDataset_Segformer_20251012.py FPCDataset-Segformer/iter_40000.pth FPCDataset-Segformer/_2-1_OK_2025-10-08-16-53-02-934.png --work-dir mmseg2ttr_segformer --device cuda:0

from mmdeploy.apis import torch2onnx
from mmdeploy.backend.sdk.export_info import export2SDK

img = 'FPCDataset-Segformer/_2-1_OK_2025-10-08-16-53-02-934.png'
work_dir = 'work_dir/'
save_file = 'end2end.onnx'
deploy_cfg = 'configs/mmseg/segmentation_onnxruntime_dynamic.py'
model_cfg = 'FPCDataset-Segformer/FPCDataset_Segformer_20251012.py'
model_checkpoint = 'FPCDataset-Segformer/iter_40000.pth'
device = 'cpu'

1. convert model to onnx

torch2onnx(img, work_dir, save_file, deploy_cfg, model_cfg,
model_checkpoint, device)

2. extract pipeline info for sdk use (dump-info)

export2SDK(deploy_cfg, model_cfg, work_dir, pth=model_checkpoint, device=device)

from mmdeploy.apis import torch2onnx
from mmdeploy.apis.tensorrt import onnx2tensorrt
from mmdeploy.backend.sdk.export_info import export2SDK
import os

1. convert model to IR(onnx)

torch2onnx(img, work_dir, save_file, deploy_cfg, model_cfg,
model_checkpoint, device)

2. convert IR to tensorrt

onnx_model = os.path.join(work_dir, save_file)
save_file = 'end2end.engine'
model_id = 0
device = 'cuda'
onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device)

3. extract pipeline info for sdk use (dump-info)

export2SDK(deploy_cfg, model_cfg, work_dir, pth=model_checkpoint, device=device)

Environment

ONNXRuntime 版本 1.16.0
Pytorch 版本 2.1.0+cu118
Pytorch 版本 0.16.0+cu118
CUDA 是否可用 True
11/18 21:21:04 - mmengine - WARNING - Failed to search registry with scope "mmseg" 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 "mmseg" is a correct scope, or whether the registry is initialized.
11/18 21:21:04 - mmengine - WARNING - Failed to search registry with scope "mmseg" in the "mmseg_tasks" registry tree. As a workaround, the current "mmseg_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmseg" is a correct scope, or whether the registry is initialized.
c:\users\asus\desktop\newpro\mmsegmentation\mmseg\models\decode_heads\decode_head.py:120: UserWarning: For binary segmentation, we suggest using`out_channels = 1` to define the outputchannels of segmentor, and use `threshold`to convert `seg_logits` into a predictionapplying a threshold
  warnings.warn('For binary segmentation, we suggest using'
c:\users\asus\desktop\newpro\mmsegmentation\mmseg\models\losses\cross_entropy_loss.py:250: UserWarning: Default ``avg_non_ignore`` is False, if you would like to ignore the certain label and average loss over non-ignore labels, which is the same with PyTorch official cross_entropy, set ``avg_non_ignore=True``.
  warnings.warn(
Loads checkpoint by local backend from path: FPCDataset-Segformer/iter_40000.pth
11/18 21:21:05 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future.
11/18 21:21:05 - mmengine - INFO - Export PyTorch model to ONNX: work_dir/end2end.onnx.
C:\Users\ASUS\Desktop\newPro\mmdeploy\mmdeploy\core\optimizers\function_marker.py:160: 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!
  ys_shape = tuple(int(s) for s in ys.shape)
c:\users\asus\desktop\newpro\mmsegmentation\mmseg\models\utils\shape_convert.py:15: TracerWarning: Converting a tensor to a Python boolean 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!
  assert L == H * W, 'The seq_len doesn\'t match H, W'
C:\Users\ASUS\Desktop\newPro\mmdeploy\mmdeploy\codebase\mmseg\models\segmentors\base.py:61: TracerWarning: Converting a tensor to a Python boolean 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!
  if seg_logit.shape[1] == 1:

Error traceback

Activity

  1. James-Zhangpp commented on Nov 18, 2025

    @James-Zhangpp
    Author

    11/18 21:24:29 - mmengine - INFO -

    11/18 21:24:29 - mmengine - INFO - Environmental information
    11/18 21:24:32 - mmengine - INFO - sys.platform: win32
    11/18 21:24:32 - mmengine - INFO - Python: 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]
    11/18 21:24:32 - mmengine - INFO - CUDA available: True
    11/18 21:24:32 - mmengine - INFO - MUSA available: False
    11/18 21:24:32 - mmengine - INFO - numpy_random_seed: 2147483648
    11/18 21:24:32 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4060 Ti
    11/18 21:24:32 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
    11/18 21:24:32 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.8, V11.8.89
    11/18 21:24:32 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.50.35717 版
    11/18 21:24:32 - mmengine - INFO - GCC: n/a
    11/18 21:24:32 - mmengine - INFO - PyTorch: 2.1.0+cu118
    11/18 21:24:32 - mmengine - INFO - PyTorch compiling details: PyTorch built with:

    • C++ Version: 199711
    • MSVC 192930151
    • Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
    • Intel(R) MKL-DNN v3.1.1 (Git Hash 64f6bcbcbab628e96f33a62c3e975f8535a7bde4)
    • OpenMP 2019
    • LAPACK is enabled (usually provided by MKL)
    • CPU capability usage: AVX2
    • CUDA Runtime 11.8
    • 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_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_90,code=sm_90;-gencode;arch=compute_37,code=compute_37
    • CuDNN 8.7
    • Magma 2.5.4
    • Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, CXX_COMPILER=C:/actions-runner/_work/pytorch/pytorch/builder/windows/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /bigobj /FS -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /utf-8 /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=OFF, TORCH_VERSION=2.1.0, 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=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,

    11/18 21:24:32 - mmengine - INFO - TorchVision: 0.16.0+cu118
    11/18 21:24:32 - mmengine - INFO - OpenCV: 4.9.0
    11/18 21:24:32 - mmengine - INFO - MMEngine: 0.10.7
    11/18 21:24:32 - mmengine - INFO - MMCV: 2.1.0
    11/18 21:24:32 - mmengine - INFO - MMCV Compiler: MSVC 192930148
    11/18 21:24:32 - mmengine - INFO - MMCV CUDA Compiler: 11.8
    11/18 21:24:32 - mmengine - INFO - MMDeploy: 1.3.1+unknown
    11/18 21:24:32 - mmengine - INFO -

    11/18 21:24:32 - mmengine - INFO - Backend information
    11/18 21:24:32 - mmengine - INFO - tensorrt: 8.6.1
    11/18 21:24:32 - mmengine - INFO - tensorrt custom ops: Available
    11/18 21:24:32 - mmengine - INFO - ONNXRuntime: 1.16.0
    11/18 21:24:32 - mmengine - INFO - ONNXRuntime-gpu: 1.16.0
    11/18 21:24:32 - mmengine - INFO - ONNXRuntime custom ops: Available
    11/18 21:24:32 - mmengine - INFO - pplnn: None
    11/18 21:24:32 - mmengine - INFO - ncnn: None
    11/18 21:24:32 - mmengine - INFO - snpe: None
    11/18 21:24:32 - mmengine - INFO - openvino: 2023.3.0
    11/18 21:24:32 - mmengine - INFO - torchscript: 2.1.0+cu118
    11/18 21:24:32 - mmengine - INFO - torchscript custom ops: NotAvailable
    11/18 21:24:32 - mmengine - INFO - rknn-toolkit: None
    11/18 21:24:32 - mmengine - INFO - rknn-toolkit2: None
    11/18 21:24:32 - mmengine - INFO - ascend: None
    11/18 21:24:32 - mmengine - INFO - coreml: None
    11/18 21:24:32 - mmengine - INFO - tvm: None
    11/18 21:24:32 - mmengine - INFO - vacc: None
    11/18 21:24:32 - mmengine - INFO -

    11/18 21:24:32 - mmengine - INFO - Codebase information
    11/18 21:24:32 - mmengine - INFO - mmdet: 3.3.0
    11/18 21:24:32 - mmengine - INFO - mmseg: 1.2.2
    11/18 21:24:32 - mmengine - INFO - mmpretrain: None
    11/18 21:24:32 - mmengine - INFO - mmocr: None
    11/18 21:24:32 - mmengine - INFO - mmagic: None
    11/18 21:24:32 - mmengine - INFO - mmdet3d: None
    11/18 21:24:32 - mmengine - INFO - mmpose: None
    11/18 21:24:32 - mmengine - INFO - mmrotate: None
    11/18 21:24:32 - mmengine - INFO - mmaction: None
    11/18 21:24:32 - mmengine - INFO - mmrazor: None
    11/18 21:24:32 - mmengine - INFO - mmyolo: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions