onnx / onnx/models

Cannot convert MaskRCNN onnx model to TensorRT

Open
#604 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Bug Report

Which model does this pertain to?

MaskRCNN-10.onnx

Describe the bug

I am trying to use tensorrt as a backend with onnx_tensorrt. I have this little piece of python code

import onnx
import onnx_tensorrt.backend as backend
import numpy as np

filename = "MaskRCNN-10.onnx"
model = onnx.load(filename)
onnx.checker.check_model(model)


model = onnx.load(filename)
engine = backend.prepare(model, device='CUDA:0')

Then, I have this error:

RuntimeError: While parsing node number 902:
ModelImporter.cpp:168 In function parseGraph:
[6] Invalid Node - 908
This version of TensorRT only supports input K as an initializer. Try applying constant folding on the model using Polygraphy: https://github.com/NVIDIA/TensorRT/tree/master/tools/Polygraphy/examples/cli/surgeon/02_folding_constants

So, I try what it says, and execute this command:

polygraphy surgeon sanitize MaskRCNN-10.onnx --fold-constants  -o folded.onnx

But, after execute this python code

import onnx
import onnx_tensorrt.backend as backend
import numpy as np

filename = "MaskRCNN-10.onnx"
model = onnx.load(filename)
onnx.checker.check_model(model)


model = onnx.load("folded10.onnx")
engine = backend.prepare(model, device='CUDA:0')

Says more or less the same error:

RuntimeError: While parsing node number 609:
ModelImporter.cpp:168 In function parseGraph:
[6] Invalid Node - 908
This version of TensorRT only supports input K as an initializer. Try applying constant folding on the model using Polygraphy: https://github.com/NVIDIA/TensorRT/tree/master/tools/Polygraphy/examples/cli/surgeon/02_folding_constants
Reproduction instructions

System Information

Ubuntu 22.04
Python 3.10.6
Onnx 1.14.0
OnnxTensorRT 8.5.1

Notes

Any additional information

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with MaskRCNN-10.onnx and the shown Python backend.prepare call, then compare it with the output of the listed Polygraphy surgeon sanitize --fold-constants command. Trace the reported invalid node and verify that the resulting model can be prepared by onnx_tensorrt without the initializer error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.