Sorry, I made a typing mistake and the display went wrong.
Re-write the script.
import sys, os, glob
import numpy as np
import tensorrt as trt
from tensorflow.keras.preprocessing.image import img_to_array, load_img
TRT_LOGGER = trt.Logger(trt.Logger.WARNING)
def build_engine_onnx(model_file, batch_size):
with trt.Builder(TRT_LOGGER) as builder, builder.create_network(common.EXPLICIT_BATCH) as network, trt.OnnxParser(network, TRT_LOGGER) as parser:
builder.max_workspace_size = common.GiB(1)
builder.fp16_mode = True
with open(model_file, 'rb') as model:
if not parser.parse(model.read()):
print('ERROR: Failed to parse the ONNX file.')
for error in range(parser.num_errors):
model_file = ‘/home/--/sample.onnx’
hold_vector = np.load(’/home/--/sample-hv.npy’)
batch_size = 32
with build_engine_onnx(model_file, batch_size) as engine, create_execution_context() as context:
serialized_engine = engine.serialize()
with open('samplename.engine', 'wb') as f:
if __name__ == "__main__":
[TensorRT] ERROR: Network has dynamic or shape inputs, but no optimization profile has been defined.
[TensorRT] ERROR: Network validation failed.
Traceback (most recent call last):
with build_engine_onnex(model_file, batch_size) as engine, engine.create_executioncontext() as contexit:
When I use the same script with Jetson NANO, I don’t get an error, so I think there is a problem with the Docker environment.
I want to use Docker to start the script, so it would be helpful if you could give me some advice on building the environment.
Thank you for your cooperation.