Using the function signatures loaded from a SavedModel requires the original trackable object be kept in scope. #46708
Labels
comp:keras
Keras related issues
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
TF 2.8
type:bug
Bug
System information
v2.4.0-rc4-71-g582c8d236cb 2.4.0
Describe the current behavior
Loading a SavedModel from disk and extracting a signature from it works only while the result of
tf.saved_model.load
has not be collected by the Python garbage collector. For example, the following code fails:but this code snippet runs successfully:
The issue can be worked around by manually attaching the original trackable object to the return value of the function, preventing the Python garbage collector from collecting the object:
The exception thrown can, depending on the model and environment, sometimes be:
The exception can also manifest as:
This may be a similar issue to #37615.
Standalone code to reproduce the issue
When run on TensorFlow 2.4.0, the above script prints:
The text was updated successfully, but these errors were encountered: