ERROR: convert mask rcnn uff model to .engine model


I am trying to build object detector by mask rcnn.

I use “mask_rcnn_coco.h5” model file from model link, and I use this repo to convert .h5 to uff model. It’s ok.

But when I convert from uff to engine file, I have some problem:

[TensorRT] ERROR: UffParser: Validator error: roi_align_mask_trt: Unsupported operation _PyramidROIAlign_TRT
[TensorRT] ERROR: Network must have at least one output
Traceback (most recent call last):
File “”, line 45, in
File “”, line 38, in main
with build_engine_uff(uff_model_file) as engine:
AttributeError: enter

import tensorrt as trt

class ModelData(object):
    MODEL_PATH = "/home/nvidia/sampleUffMaskRCNN/data_05/mrcnn_nchw.uff"
    INPUT_NAME = "input_image"
    INPUT_SHAPE = (3,1024,1024)
    OUTPUT_NAME = ["mrcnn_detection", "mrcnn_mask/Sigmoid"]
    DTYPE = trt.float32

TRT_LOGGER = trt.Logger(trt.Logger.WARNING)

def build_engine_uff(model_file):
    with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.UffParser() as parser:
        builder.max_workspace_size = 1 << 20
        parser.register_input(ModelData.INPUT_NAME, ModelData.INPUT_SHAPE)
        parser.parse(model_file, network)
        return builder.build_cuda_engine(network)

def main():
    uff_model_file = ModelData.MODEL_PATH
    with build_engine_uff(uff_model_file) as engine:
        with open('{}_{}.engine'.format("mask", 'rcnn'), 'wb') as f:
            print("writing engine")

if __name__ == '__main__':

How can I fix it?

Many thanks !

Link model:
Link convert .h to uff:


Could you please share the set-up details so we can better help?


TensorRT Version :
GPU Type :
Nvidia Driver Version :
CUDA Version :
CUDNN Version :
Operating System + Version :
Python Version (if applicable) :
TensorFlow Version (if applicable) :
PyTorch Version (if applicable) :
Baremetal or Container (if container which image + tag) :


Hi SunilJB,

My device info:


TensorRT Version : 5.1
GPU Type : NVIDIA Tegra X2
Nvidia Driver Version : 32.2.3
CUDA Version : 10.0.326
CUDNN Version : v7
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 5

Operating System + Version : Ubuntu 18.04.3 LTS
Python Version (if applicable) : 3.6.9
TensorFlow Version (if applicable) : 1.14.0
PyTorch Version (if applicable) : None
Baremetal or Container (if container which image + tag) : None


MaskRCNN samples support was added in TRT 6. Request you to please try TRT6 release.
In TRT 6 this sample is available only in GitHub and is not packaged with the product.


Hi SunilJB,

I will try, thanks you!