Skip to content

ValueError: Failed to parse the ONNX file. #2

Description

@CodeSnailss

作者大大,你好。十分感谢您提供的从ONNX转换到TensorRT的方案,我目前遇到了一些困难

当我传入build_engine()的ONNX是batch_size为16的形式,它将会报出下面的错误

[10/30/2024-15:24:45] [TRT] [I] Found regisitered local function: stylesync_model_Upsample_generator_to_rgbs_6_upsample_1. Checking as a local function.
[10/30/2024-15:24:45] [TRT] [I] Found regisitered local function: aten_constant_pad_nd|inlined_40. Checking as a local function.
[10/30/2024-15:24:45] [TRT] [I] Found regisitered local function: aten_constant_pad_nd|inlined_41. Checking as a local function.
[10/30/2024-15:24:46] [TRT] [E] In node -1 with name:  and operator:  (convMultiInput): UNSUPPORTED_NODE: Assertion failed: checkSpatialDims(kernel_tensor_ptr->getDimensions()) && "The input tensor shape misaligns with the input kernel shape."
Traceback (most recent call last):
  File "test_convert_engine.py", line 26, in <module>
    feature_engine = build_engine(feature2image_path, precision='fp16', dynamic_shapes=dynamic_shapes)
  File "/autodl-fs/data/digital_human/SSCODE/convert_tensorrt.py", line 27, in build_engine
    raise ValueError('Failed to parse the ONNX file.')
ValueError: Failed to parse the ONNX file.

下面的是我的input和output的shapes

Model Input and Output Shapes:

Inputs:
  - Name: l_face_sequences_, Shape: [16, 6, 512, 512]
  - Name: l_audio_feat_, Shape: [16, 512]

Outputs:
  - Name: act_1, Shape: [16, 3, 512, 512]

这是我利用build_engine的代码

feature2image_path = "compile/f2i/video20241014_150313/feature2image.onnx"

batch_size = 16

dynamic_shapes = {
    'min_shape': [1, 3, 256, 256],
    'opt_shape': [max(1, batch_size // 2), 3, 512, 512],
    'max_shape': [batch_size, 3, 960, 960]
}

feature_engine = build_engine(feature2image_path, precision='fp16', dynamic_shapes=dynamic_shapes)
print("feature engine built successfully!")

如果您可以帮助解决我的困惑的话,我将不胜感激。(^U^)ノ~YO

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions