Unable to create a .enginefile on Jetson Nano


I’m unable to create a .engine file on Jetson Nano

Here is my code used

import requests
import tensorflow as tf
import tensorrt as trt
import graphsurgeon as gs
import ctypes
import uff


uff_model_path = "tmp.uff"
engine_path = "ssd_mobilenet_v2_exam.engine"
TRT_LOGGER = trt.Logger(trt.Logger.WARNING)
trt.init_libnvinfer_plugins(TRT_LOGGER, '')

trt_runtime = trt.Runtime(TRT_LOGGER)

with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.UffParser() as parser:
  builder.max_workspace_size = 1 << 30
  builder.fp16_mode = True
  builder.max_batch_size = 1
  parser.register_input("Input", (3, 300, 300))
  parser.parse(uff_model_path, network)
  print("Building TensorRT engine, this may take a few minutes...")
  trt_engine = builder.build_cuda_engine(network)

also tried tensorrt.utils.write_engine_to_file but got the same error tensorrt has not attribute legacy or utils.
I’m using TRT version shipped with Jetson Nano Ubuntu file

I have the same problem, parser.parse returns False and I read this error. [TensorRT] ERROR: UffParser: Validator error: GridAnchor: Unsupported operation _GridAnchor_TRT
my version of TRT is ‘’

Linux JetsonNano 4.9.140-tegra #1 SMP PREEMPT Tue Jul 16 17:04:49 PDT 2019 aarch64 aarch64 aarch64 GNU/Linux
Ubuntu 18.04.3 LTS

* Type:           NANO/TX1
* Jetpack:        4.2.1 [L4T 32.2.0]
* GPU-Arch:       5.3

* CUDA:           10.0.326
* cuDNN:
* TensorRT:
* VisionWorks:
* OpenCV:         4.1.0 compiled CUDA: YES

Hi psgr,

You can just open a file normally and write the serialized engine to it, you don’t need a special function. Example:

with builder.build_cuda_engine(network) as engine, open("model.engine", "wb") as f:

Let me know if you still have issues.

NVIDIA Enterprise Support