tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.49k stars 1.67k forks source link

Bug: No attribute '_to_proto_fn error while importing tensorflow_hub #883

Closed cfRod closed 1 year ago

cfRod commented 1 year ago

What happened?

I am trying to import tensorflow_hub with the latest tensorflow master (2.13) to run benchmarks and do some testing but It is missing "_to_proto_fn " attributed that was recently removed from TensorFlow master https://github.com/tensorflow/tensorflow/commit/1daec110903211cfc8a320485d383e2a04b67372

Relevant code

import tensorflow_hub as hub

Relevant log output

python image_classification_with_tf_hub.py 
2023-04-21 08:57:01.263046: I tensorflow/core/util/port.cc:116] Experimental oneDNN custom operations are on. If you experience issues, please turn them off by setting the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
Traceback (most recent call last):
  File "/home/ubuntu/fixedformat/model-zoo/image_classification_with_tf_hub.py", line 55, in <module>
    import tensorflow_hub as hub
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow_hub/__init__.py", line 90, in <module>
    from tensorflow_hub.estimator import LatestModuleExporter
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow_hub/estimator.py", line 62, in <module>
    class LatestModuleExporter(tf_estimator.Exporter):
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py", line 58, in __getattr__
    module = self._load()
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow/python/util/lazy_loader.py", line 41, in _load
    module = importlib.import_module(self.__name__)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow_estimator/__init__.py", line 8, in <module>
    from tensorflow_estimator._api.v1 import estimator
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow_estimator/_api/v1/estimator/__init__.py", line 11, in <module>
    from tensorflow_estimator._api.v1.estimator import tpu
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow_estimator/_api/v1/estimator/tpu/__init__.py", line 12, in <module>
    from tensorflow_estimator.python.estimator.tpu.tpu_estimator import TPUEstimator
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py", line 118, in <module>
    to_proto=resource_variable_ops._to_proto_fn,  # pylint: disable=protected-access
AttributeError: module 'tensorflow.python.ops.resource_variable_ops' has no attribute '_to_proto_fn'

tensorflow_hub Version

0.13.0.dev (unstable development build)

TensorFlow Version

other (please specify)

Other libraries

tensorflow 2.13.0

Python Version

3.x

OS

Linux

elfringham commented 1 year ago

@cfRod You need to be using the latest versions of keras-nightly, tb-nightly and tf-estimator-nightly instead of keras, tensorboard and tensorflow-estimator. The released versions are not compatible with current TensorFlow master.

cfRod commented 1 year ago

Thanks @elfringham ,

I was able to import tensorflow_hub now. I do have another message that has cropped up with absl

ERROR:absl:Unable to load fingerprint when loading saved model.
Traceback (most recent call last):
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow/python/saved_model/load.py", line 1015, in load_partial
    fingerprint = fingerprinting.read_fingerprint(export_dir)
  File "/home/ubuntu/python3-venv/lib/python3.10/site-packages/tensorflow/python/saved_model/fingerprinting.py", line 172, in read_fingerprint
    raise FileNotFoundError(f"SavedModel Fingerprint Error: {e}") from None  # pylint: disable=raise-missing-from
FileNotFoundError: SavedModel Fingerprint Error: Could not read fingerprint from directory: /tmp/tfhub_modules/1a05e7638ff9b16c4dece6468cb6cd6ec4173fd1
singhniraj08 commented 1 year ago

@cfRod,

Can you try installing tensorflow and tensorflow_hub as shown here. I tried the same setup and was able to import tensorflow_hub without any errors. Thanks!

!pip install tf-nightly
!pip install --upgrade tf-hub-nightly
Screenshot 2023-04-24 at 11 15 05 AM
WGierke commented 1 year ago

Hi @cfRod The message you're seeing is just a log message. Can you confirm that you were still able to load the model?

cfRod commented 1 year ago

Hi both, yes I can still load the model.

singhniraj08 commented 1 year ago

@cfRod, Thank you for the confirmation. Requesting you to close this issue if your issue is resolved.

google-ml-butler[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No

singhniraj08 commented 1 year ago

Closing this due to inactivity. Please take a look into the answers provided above, feel free to reopen and post your comments(if you still have queries on this). Thank you!

google-ml-butler[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No