TF-TRT graph conversion failed for Tensorflow version 1

Description

I’m trying build tensorflow optimised model with TF-TRT path. Throwing the below error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/importer.py", line 501, in _import_graph_def_internal
    graph._c_graph, serialized, options)  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input 1 of node StatefulPartitionedCall was passed float from Conv1/kernel:0 incompatible with expected resource.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tf_trt_handson.py", line 17, in <module>
    tf_trt_converter.save('mobilenetv2'+'_'+PRECISION)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/compiler/tensorrt/trt_convert.py", line 713, in save
    importer.import_graph_def(self._converted_graph_def, name="")
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/util/deprecation.py", line 513, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/importer.py", line 405, in import_graph_def
    producer_op_list=producer_op_list)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/importer.py", line 505, in _import_graph_def_internal
    raise ValueError(str(e))
ValueError: Input 1 of node StatefulPartitionedCall was passed float from Conv1/kernel:0 incompatible with expected resource.

Environment

TensorRT Version : 8.2.1.8-1+cuda10.2
GPU Type : Jetson nano
Nvidia Driver Version : CUDA Driver Version: 10.2
CUDA Version : cuda-toolkit-10-2 (= 10.2.460-1)
CUDNN Version : cuDNN Version: 8.2
Operating System + Version : Ubuntu 18.04(l4t with jetpack)
Python Version (if applicable) : 3.6.9
TensorFlow Version (if applicable) : ‘1.15.5’
PyTorch Version (if applicable) :
Baremetal or Container (if container which image + tag) :

Relevant Files

-----model saving code----

from matplotlib import pyplot as plt
import numpy as np
import tensorflow as tf

file = tf.keras.utils.get_file(
    "grace_hopper.jpg",
    "https://storage.googleapis.com/download.tensorflow.org/example_images/grace_hopper.jpg")
img = tf.keras.preprocessing.image.load_img(file, target_size=[224, 224])
plt.imshow(img)
plt.axis('off')
x = tf.keras.preprocessing.image.img_to_array(img)
x = tf.keras.applications.mobilenet_v2.preprocess_input(x[tf.newaxis,...])

labels_path = tf.keras.utils.get_file(
    'ImageNetLabels.txt',
    'https://storage.googleapis.com/download.tensorflow.org/data/ImageNetLabels.txt')
imagenet_labels = np.array(open(labels_path).read().splitlines())
print('Imagenet labels: ',imagenet_labels)

pretrained_model = tf.keras.applications.MobileNetV2()
result_before_save = pretrained_model(x)
print('Result before save: ',result_before_save)

#decoded = imagenet_labels[np.argsort(result_before_save)[0,::-1][:5]+1]

#print("Result before saving:\n", decoded)


mobilenet_saved_path = ('tensorrt/tf_trt')
tf.saved_model.save(pretrained_model, mobilenet_saved_path)

-----tf-trt—

import tensorflow as tf
from tensorflow.keras.applications import MobileNetV2
import numpy as np
from tensorflow.python.compiler.tensorrt import trt_convert as tf_trt


BATCH_SIZE = 32

#we generate a dummy batch of data to pass into the network just to get an understanding of its performance. 
#This is normally where you would supply a numpy batch of images.
dummy_input_batch = np.zeros((BATCH_SIZE, 224, 224, 3))

PRECISION = 'FP32'

tf_trt_converter = tf_trt.TrtGraphConverter(input_saved_model_dir='/home/aitrios/tensorrt/tf_trt',precision_mode=PRECISION)
tf_trt_converter.convert()
tf_trt_converter.save('mobilenetv2'+'_'+PRECISION)

Steps To Reproduce

Kindly refer the code snipped attached.

Hi,
We recommend you to check the below samples links in case of tf-trt integration issues.

If issue persist, We recommend you to reach out to Tensorflow forum.
Thanks!