I am trying to load a model that was exported to saved_model format using tensorflow version 2.10. Now I need to load that saved model in tensorflow 2.7. This is a requirement since I need to run the model on Nvidia's Jetson Nano which does not support tensorflow version > 2.7. Loading the model gives me this error.
KeyError Traceback (most recent call last)
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\tensorflow\python\framework\ops.py in _get_op_def(self, type)
4097 try:
-> 4098 return self._op_def_cache[type]
4099 except KeyError:
KeyError: 'DisableCopyOnRead'
During handling of the above exception, another exception occurred:
NotFoundError Traceback (most recent call last)
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\tensorflow\python\saved_model\load.py in load_internal(export_dir, tags, options, loader_cls, filters)
938 loader = loader_cls(object_graph_proto, saved_model_proto, export_dir,
--> 939 ckpt_options, options, filters)
940 except errors.NotFoundError as err:
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\tensorflow\python\saved_model\load.py in __init__(self, object_graph_proto, saved_model_proto, export_dir, ckpt_options, save_options, filters)
138 function_deserialization.load_function_def_library(
--> 139 meta_graph.graph_def.library, wrapper_function=_WrapperFunction))
140 self._checkpoint_options = ckpt_options
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\tensorflow\python\saved_model\function_deserialization.py in load_function_def_library(library, load_shared_name_suffix, wrapper_function)
387 with graph.as_default():
--> 388 func_graph = function_def_lib.function_def_to_graph(copy)
...
943 "from the computational device. Consider setting the "
944 "`experimental_io_device` option in `tf.saved_model.LoadOptions` "
FileNotFoundError: Op type not registered 'DisableCopyOnRead' in binary running on LAPTOP-V4DO1PQN. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
You may be trying to load on a different device from the computational device. Consider setting the `experimental_io_device` option in `tf.saved_model.LoadOptions` to the io_device such as '/job:localhost'.
The issue seems to be version compatibility since the model loads fine in tensorflow version 2.10 and greater. Is there a way to get around this and be able to run inference using the model in version 2.7?
The model is MoViNet from tf-models-official. I tried to build the model using tensorflow 2.7 but tf-models-official requires version >=2.10.
Using tensorflow 2.7 gives following error on this import statement
from official.projects.movinet.modeling import movinet
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_21808\565483761.py in <module>
1 import pathlib
2 import tensorflow as tf
----> 3 from official.projects.movinet.modeling import movinet
4 from official.projects.movinet.modeling import movinet_model
5 from official.projects.movinet.tools import export_saved_model
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\official\projects\movinet\modeling\movinet.py in <module>
24
25 from official.modeling import hyperparams
---> 26 from official.projects.movinet.modeling import movinet_layers
27 from official.vision.modeling.backbones import factory
28
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\official\projects\movinet\modeling\movinet_layers.py in <module>
23
24 from official.modeling import tf_utils
---> 25 from official.vision.modeling.layers import nn_layers
26
27 # Default kernel weight decay that may be overridden
c:\Users\Hammad\anaconda3\envs\temp\lib\site-packages\official\vision\__init__.py in <module>
15 """Vision package definition."""
...
---> 36 'adamw_experimental': tf.keras.optimizers.experimental.AdamW,
37 'lamb': tfa_optimizers.LAMB,
38 'rmsprop': tf.keras.optimizers.RMSprop,
AttributeError: module 'tensorflow.keras.optimizers' has no attribute 'experimental'
I just need a way to run the model on Jetson nano.