AttributeError: 'module' object has no attribute 'infer'

Hello

I have a problem with TensorRT and its implementation in TensorFlow.
My code is:

import tensorflow as tf
import tensorrt 
import pycuda.driver as cuda
import pycuda.autoinit
import numpy as np
from PIL import Image
import time
import os
import uff

OUTPUT_NAMES = ['DepthToSpace']
export_dir = "/data/Xiph_defs_collection_4K_Preview_19EA/pb/11909700/"

with tf.Session(graph=tf.Graph()) as sess:
    tf.saved_model.loader.load(sess, [tf.saved_model.tag_constants.GPU], export_dir)
    graphdef = tf.get_default_graph().as_graph_def()
    frozen_graph = tf.graph_util.convert_variables_to_constants(sess,
    graphdef,
    OUTPUT_NAMES)    
    tf_model = tf.graph_util.remove_training_nodes(frozen_graph)
    uff_model = uff.from_tensorflow(tf_model, OUTPUT_NAMES)

G_LOGGER = trt.infer.ConsoleLogger(trt.infer.LogSeverity.ERROR)

Error is:

AttributeError                            Traceback (most recent call last)
<ipython-input-14-69202d011f11> in <module>()
----> 1 G_LOGGER = trt.infer.ConsoleLogger(trt.infer.LogSeverity.ERROR)

AttributeError: 'module' object has no attribute 'infer'

I’m following this tutorial
https://github.com/Microsoft/MMdnn/wiki/Using-TensorRT-to-Accelerate-Inference

My environment
Ubuntu 16.04
TF r1.12 (built from source)
TensorRT 5.0.2.6
Python 2.7
CUDA V10.0.130
cuDNN 7.4.1
NVIDIA GPU - GTX1080 TI

I solved this issue with this solution:

https://devtalk.nvidia.com/default/topic/1046258/tensorrt/onnx-tensorrt-install-test-failure/

This error happens because there is no attribute with the name you called, for that Object. This means that you got the error when the “module” does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the python source code after you had already imported the file (module). Or, some times packages get deprecated and they rename some functions. If that is true, then you may want to exit and reimport the module once again to be able to access the new method. You can do it in another way to reimport the module with changes without having to exit the interpreter is to do the following:

import importlib
importlib.reload(myModule)