Error in converting frozen graph to Tensor RT engine

Hello,

I am following this GitHub - NVIDIA-AI-IOT/tf_to_trt_image_classification: Image classification with NVIDIA TensorRT from TensorFlow models. link for my Xavier for Tensorflow to Tensor RT image classification.

I have installed Jetpack 4.2 which included Tensor RT 5.0.6.

I got the uff error which I solved by downloading tar file “TensorRT-5.0.2.6.Ubuntu-18.04.1.x86_64-gnu.cuda-10.0.cudnn7.3” and installed wheel package for uff.

Also installed graphsurgeon wheel package from same tar file.

I am able to create frozen graphs.

But I get error in converting frozen graph to Tensor RT engine or Plan file.

I fired following command from root path of project:

python scripts/convert_plan.py data/frozen_graphs/mobilenet_v1_1p0_224.pb data/plans/mobilenet.plan input 224 224 MobilenetV1/Logits/SpatialSqueeze 1 0 half

I got following error:

Using output node MobilenetV1/Logits/SpatialSqueeze
Converting to UFF graph
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_13_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_12_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_12_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_11_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_11_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_10_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_10_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_9_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_9_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_8_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_8_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_7_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_7_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_6_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_6_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_5_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_5_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_4_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_4_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_3_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_3_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_2_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_2_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_1_pointwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_1_depthwise/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
Warning: No conversion function registered for layer: FusedBatchNormV3 yet.
Converting MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/FusedBatchNormV3 as custom op: FusedBatchNormV3
No. nodes: 306
UFF Output written to data/tmp.uff
UFFParser: Validator error: MobilenetV1/MobilenetV1/Conv2d_13_depthwise/BatchNorm/FusedBatchNormV3: Unsupported operation _FusedBatchNormV3
Failed to parse UFF

Also, I have tried another model “resnet_v1_50” in which I got the same error.

Please help me with this.

Thanks in advance.

Hi,

Usually, mobilenet requires a custom config.py file.
We have a sample for ssd_mobilenet_v1. Would you mind to check if this sample fix your issue first?
[url]https://github.com/AastaNV/TRT_object_detection[/url]

Thanks.

Hello @AastaLL

Thanks for reponse.

I followed steps in link.

I got following error while running: python main.py car.jpg

Traceback (most recent call last):
File “main.py”, line 23, in
TRT_LOGGER = trt.Logger(trt.Logger.INFO)
AttributeError: module ‘tensorrt’ has no attribute ‘Logger’

Hi,

Please execute it with python3.

Like:

python3 main.py car.jpg

Thanks.

I have tried :

python3 main.py car.jpg

I have tried importing on python shell of Tensor RT versions :5.0.6 and 5.1.5

import tensorflow.contrib.tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.INFO)

But this “AttributeError: module ‘tensorrt’ has no attribute ‘Logger’” error still persists.

I have checked Tensor RT versions using : dpkg -l | grep nvinfer

Please help me.

Hi,

Do you use Jeston Xavier?

If yes, please install all the package with JetPack4.2.
TensorRT5.1.5 is not available for Jeston yet.

Thanks.

I have Jetpack 4.2 installed on Jetson Xavier. Its Tensor RT version is 5.0.6.

Also, I installed Tensor RT 5.1.5 on my PC with ubuntu 18.04 and tried the same.

But on both platform I got the same error.

Hi,

Sorry for the missing.

This sample requires pure TensorRT package rather than TF-TRT.
So you will need to import TensorRT like this :

import tensorrt as trt

Don’t use the one from the tensorflow.contrib.
Thanks.

Hello I have tried following on python shell.

import tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.INFO)

But still it throws same error.

AttributeError: module ‘tensorrt’ has no attribute ‘Logger’"

It seems likely that the runtime optimized tensorflow doesn’t have a logger.
You might want to import a Logger from somewhere else, or write an interface that implements whatever you need the Logger for.
(In general, during inference, you don’t want to log anything at runtime, because doing so will consume more resources and can reduce frame rate.)
Or just replace your Logger calls with print statements.

Hi @snarky

I am using Tensor RT Logger and not Tensorflow. Actually I am getting error for many functions like: Logger, Builder and DataType. I get same error for all these.

@AastaLLL
I have created sample.py containing these two lines but still getting errors:

import tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.INFO)

Also, I have tried to run sample “tensorrt/samples/python/uff_ssd”

I fired command :

python detect_objects.py images/image2.jpg

It throws errors:
Traceback (most recent call last):
File “detect_objects.py”, line 11, in
import utils.inference as inference_utils # TRT/TF inference wrappers
File “/usr/src/tensorrt/samples/python/uff_ssd/utils/inference.py”, line 13, in
import utils.engine as engine_utils # TRT Engine creation/save/load utils
File “/usr/src/tensorrt/samples/python/uff_ssd/utils/engine.py”, line 9, in
from utils.model import ModelData
File “/usr/src/tensorrt/samples/python/uff_ssd/utils/model.py”, line 12, in
from utils.paths import PATHS
File “/usr/src/tensorrt/samples/python/uff_ssd/utils/paths.py”, line 7, in
class Paths(object):
File “/usr/src/tensorrt/samples/python/uff_ssd/utils/paths.py”, line 56, in Paths
def get_engine_path(self, inference_type=trt.DataType.FLOT, max_batch_size=1):
AttributeError: module ‘tensorrt’ has no attribute ‘DataType’

I solved the problem. What I have done is:

I have removed Tensorflow 1.13 and installed 1.12. I deleted all the virtual environment. Made No changes to Jetpack 4.2 and its Tensor RT versions.

But still I could not find what was the issue.

Thanks