Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'EmbeddingVariable' object has no attribute '_is_primary' When using import_meta_graph #87

Closed
Lihengwannafly opened this issue Feb 23, 2022 · 2 comments
Assignees

Comments

@Lihengwannafly
Copy link

Describe the current behavior

  File "/root/workspace/rec-rank-train/vmax/estimator/estimator_v2.py", line 122, in export_big_model
    self.estimator_core.export_big_model(server, checkpoint_path=checkpoint_path)
  File "/root/workspace/rec-rank-train/vmax/core/estimator_core_v2.py", line 415, in export_big_model
    tf.train.import_meta_graph(meta_graph_or_file='/tmp/saved_model/tmp.meta')
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 1695, in import_meta_graph
    return _import_meta_graph_with_return_elements(meta_graph_or_file,
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 1723, in _import_meta_graph_with_return_elements
    saver = _create_saver_from_imported_meta_graph(meta_graph_def, import_scope,
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 1744, in _create_saver_from_imported_meta_graph
    return Saver()
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 1033, in __init__
    self.build()
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 1045, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 1112, in _build
    self.saver_def = self._builder._build_internal(  # pylint: disable=protected-access
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 656, in _build_internal
    restore_op = self._AddRestoreOps(filename_tensor, saveables,
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saver.py", line 491, in _AddRestoreOps
    assign_ops.append(saveable.restore(saveable_tensors, shapes))
  File "/usr/local/lib/python3.8/dist-packages/tensorflow_core/python/training/saving/saveable_object_util.py", line 185, in restore
    with ops.control_dependencies(None if self.var._is_primary else [self.var._primary.initializer]):
AttributeError: 'EmbeddingVariable' object has no attribute '_is_primary'

Code to reproduce the issue

  meta_graph_def = tf.train.export_meta_graph()
  meta_graph_def.meta_info_def.meta_graph_version = str(int(time.time()))
  self.logger.info('meta_graph_version = %s' %
                   meta_graph_def.meta_info_def.meta_graph_version)
  tf.reset_default_graph()
  tf.train.import_meta_graph(meta_graph_def)

and

  meta_graph_def = tf.train.export_meta_graph(filename='/tmp/saved_model/tmp.meta')
  meta_graph_def.meta_info_def.meta_graph_version = str(int(time.time()))
  self.logger.info('meta_graph_version = %s' %
                   meta_graph_def.meta_info_def.meta_graph_version)
  tf.reset_default_graph()
  tf.train.import_meta_graph(meta_graph_or_file='/tmp/saved_model/tmp.meta')
@Lihengwannafly
Copy link
Author

Lihengwannafly commented Feb 23, 2022

But if I import_meta_graph from checkpoint.meta, it works.

tf.reset_default_graph()
saver = tf.train.import_meta_graph('{}.meta'.format(latest_checkpoint_path))

@liutongxuan
Copy link
Member

liutongxuan commented Mar 25, 2022

Fixed by #128, PR merged. @Lihengwannafly please help to verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants