[Tensorflow] module 'tensorflow_core._api' has no attribute 'v2'

Finally, I’m using tf_core and solved my problem, as follows:

import tensorflow_core as tf_core
tf.compat.v1.enable_eager_execution()
tf_core.python.saved_model.load('model/trt_int8', tags=[trt.tag_constants.SERVING])

  • Jetpack 4.4 DP
  • tensorflow-2.1.0+nv20.4-cp36-cp36m-linux_aarch64

When I was trying loading my tensor rt model, some error occur:

tf.saved_model.load('model/trt_int8', tags=[trt.tag_constants.SERVING])
>>>TypeError: load() missing 1 required positional argument: 'export_dir'

Then, I found load() func require “sess”:

tf.saved_model.load()
>>>TypeError: load() missing 3 required positional arguments: 'sess', 'tags', and 'export_dir'

Enable eager execution, nothing better:

tf.compat.v1.enable_eager_execution()
tf.saved_model.load()
>>>TypeError: load() missing 3 required positional arguments: 'sess', 'tags', and 'export_dir'

Finally, I’m trying use tensorflow_core api.

import tensorflow_core as tf_core
tf_core._api.v2.saved_model.load('model/trt_int8', tags=[trt.tag_constants.SERVING])
>>> AttributeError: module 'tensorflow_core._api' has no attribute 'v2'

How to solve this issue,
Thanks.

What kind of model are you trying to load? A HDF5 or a SaveModel? Also did you check the documentation here? I usually use tf.keras.models.load_model to load serialized models.

Saved model

This code will work in my host PC.

Hi,

Thanks for your report.
This issue is related to TensorFlow version and the source which is built with.

Please check this comment for information:

Thanks.

1 Like