I’ve followed the DEEP LEARNING SDK DOCUMENTATION to learn to use TensorRT on TX2.
What I want to do is load a model from onnx (converted from mxnet) and convert it to a engine (save it) and do inference. The following is my current code (exclude inference):
import tensorrt as trt TRT_LOGGER = trt.Logger(trt.Logger.WARNING) model_path = './model.onnx' builder = trt.Builder(TRT_LOGGER) network = builder.create_network() parser = trt.OnnxParser(network, TRT_LOGGER) with open(model_path, 'rb') as model: parser.parse(model.read()) builder.max_batch_size = 5 builder.max_workspace_size = 1 << 20 engine = builder.build_cuda_engine(network) with open('sample.engine', 'wb') as f: f.write(engine.serialize())
However, the engine seems to be None and I don’t know what is wrong and what to do next. The code in DEEP LEARNING DSK DOCUMENTATION is not very clear to me.