Python run LPRNet with TensorRT show pycuda._driver.MemoryError: cuMemHostAlloc failed: out of memory

@3204657659 @distantyy
The lprnet trt engine has dynamic shape.
Please change below

  • batch-size
  • pre/post processing

For reference,
change

def allocate_buffers(engine, batch_size=1)

to

def allocate_buffers(engine, batch_size=-1)

Add below two lines

input_shape = (1,3,48,96)
context.set_binding_shape(0, input_shape)

before
outputs = do_inference(context, bindings=bindings, inputs=inputs, outputs=outputs, stream=stream)

In preprocessing, after resizing, please divide it by 255.0 , and then transpose image batch from NHWC to NCHW

2 Likes