Unable to create a .enginefile on Jetson Nano

Hi,

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

ctypes.CDLL("/home/jet/TRT/lib/libflattenconcat.so")

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.register_output("MarkOutput_0")
  parser.parse(uff_model_path, network)
  
  print("Building TensorRT engine, this may take a few minutes...")
  trt_engine = builder.build_cuda_engine(network)
  trt.legacy.utils.write_engine_to_file("./ssd_mobilenet_v2_exam.engine",trt_engine.serialize())

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 ‘5.1.6.1’

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:          7.5.0.56-1+cuda10.0
* TensorRT:       5.1.6.1-1+cuda10.0
* VisionWorks:    1.6.0.500n
* 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:
    f.write(engine.serialize())

Let me know if you still have issues.

NVIDIA Enterprise Support