Repository navigation
[Bug] 转换模型直接退出程序了,能不能帮忙解决一下 #2926
Description
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:
Activity
James-Zhangpp commentedon Nov 18, 2025
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:
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