Description
I am using python to create a TensorRT Engine for ResNet 50 from Onnx Model. The input size is (-1, 224, 224, 3)
. I am using Python, I tried to replicate the provided code in C++ as all batching samples are C++ and there are some API differences.
The final code I have is:
EXPLICIT_BATCH = 1 << (int)( trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH) with trt.Builder(TRT_LOGGER) as builder, builder.create_builder_config() as config, builder.create_network(EXPLICIT_BATCH) as network, trt.OnnxParser(network, TRT_LOGGER) as parser: with open(modelfile, 'rb') as model: if not parser.parse(model.read()): for error in range(parser.num_errors): print(parser.get_error(error)) dims = network.get_input(0).shape ilayer = network.add_input("foo", trt.float32, (3, 224, 224)) resizeLayer = network.add_resize(ilayer) resizeLayer.shape = dims network.mark_output(resizeLayer.get_output(0)) profile = builder.create_optimization_profile() profile.set_shape("foo", (1, 3, 224, 224), (5, 3, 224, 224), (50, 3, 224, 224)) config.add_optimization_profile(profile) with builder.build_engine(network, config) as engine: return engine It gave me errors:
[TensorRT] ERROR: (Unnamed Layer* 138) [Resize]: mismatch in number of dimensions for outputDims. [TensorRT] ERROR: (Unnamed Layer* 138) [Resize]: mismatch in number of dimensions for outputDims. [TensorRT] ERROR: Layer (Unnamed Layer* 138) [Resize] failed validation [TensorRT] ERROR: Network validation failed. Traceback (most recent call last): File "convert.py", line 62, in <module> main(sys.argv[1:]) File "convert.py", line 57, in main engine = build_engine(inputfile) File "convert.py", line 32, in build_engine with builder.build_engine(network, config) as engine: AttributeError: __enter__ Environment
TensorRT Version: 7.0.0.11
GPU Type: Nvida 108
Nvidia Driver Version: 440.64.00
CUDA Version: 10.2
CUDNN Version: V10.2.89
Operating System + Version:
Python Version (if applicable):
TensorFlow Version (if applicable):
PyTorch Version (if applicable):
Baremetal or Container (if container which image + tag):
Relevant Files
Please attach or include links to any models, data, files, or scripts necessary to reproduce your issue. (Github repo, Google Drive, Dropbox, etc.)
Steps To Reproduce
Please include:
- Exact steps/commands to build your repro
- Exact steps/commands to run your repro
- Full traceback of errors encountered