Issue
I have installed TensorFlow_hub from conda by doing this:
conda install -c conda-forge tensorflow-hub
However, when I try to import tensorflow_hub anywhere, I get this error;
AttributeError Traceback (most recent call last)
/tmp/ipykernel_14843/980229998.py in <module>
1 import tensorflow as tf
----> 2 import tensorflow_hub as hub
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_hub/__init__.py in <module>
86
87
---> 88 from tensorflow_hub.estimator import LatestModuleExporter
89 from tensorflow_hub.estimator import register_module_for_export
90 from tensorflow_hub.feature_column import image_embedding_column
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_hub/estimator.py in <module>
60
61
---> 62 class LatestModuleExporter(tf.compat.v1.estimator.Exporter):
63 """Regularly exports registered modules into timestamped directories.
64
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow/python/util/lazy_loader.py in __getattr__(self, item)
60
61 def __getattr__(self, item):
---> 62 module = self._load()
63 return getattr(module, item)
64
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow/python/util/lazy_loader.py in _load(self)
43 """Load the module and insert it into the parent's globals."""
44 # Import the target module and insert it into the parent's namespace
---> 45 module = importlib.import_module(self.__name__)
46 self._parent_module_globals[self._local_name] = module
47
~/anaconda3/envs/PoseEstimation/lib/python3.9/importlib/__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/api/__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.api._v1 import estimator
11
12 del _print_function
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator.python.estimator.api._v1.estimator import experimental
11 from tensorflow_estimator.python.estimator.api._v1.estimator import export
12 from tensorflow_estimator.python.estimator.api._v1.estimator import inputs
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_estimator/__init__.py in <module>
8 import sys as _sys
9
---> 10 from tensorflow_estimator._api.v1 import estimator
11
12 del _print_function
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_estimator/_api/v1/estimator/__init__.py in <module>
11 from tensorflow_estimator._api.v1.estimator import export
12 from tensorflow_estimator._api.v1.estimator import inputs
---> 13 from tensorflow_estimator._api.v1.estimator import tpu
14 from tensorflow_estimator.python.estimator.canned.baseline import BaselineClassifier
15 from tensorflow_estimator.python.estimator.canned.baseline import BaselineEstimator
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_estimator/_api/v1/estimator/tpu/__init__.py in <module>
12 from tensorflow_estimator.python.estimator.tpu.tpu_config import RunConfig
13 from tensorflow_estimator.python.estimator.tpu.tpu_config import TPUConfig
---> 14 from tensorflow_estimator.python.estimator.tpu.tpu_estimator import TPUEstimator
15 from tensorflow_estimator.python.estimator.tpu.tpu_estimator import TPUEstimatorSpec
16
~/anaconda3/envs/PoseEstimation/lib/python3.9/site-packages/tensorflow_estimator/python/estimator/tpu/tpu_estimator.py in <module>
106
107 # Track the adoption of TPUEstimator
--> 108 _tpu_estimator_gauge = tf.compat.v2.__internal__.monitoring.BoolGauge(
109 '/tensorflow/api/tpu_estimator',
110 'Whether the program uses tpu estimator or not.')
AttributeError: module 'tensorflow._api.v2.compat.v2.__internal__' has no attribute 'monitoring'
My TensorFlow versions as per conda list in the current environment are as follows:
tensorflow 2.4.1
tensorflow-base 2.4.1
tensorflow-estimator 2.6.0
tensorflow-gpu 2.4.1
tensorflow-hub 0.12.0
What do I do to import tfhub without any error?
Thank You
Solution
The environment mentioned below are worked for me
tensorflow-2.4.1
tensorflow-estimator-2.4.0
tensorflow-gpu-2.4.1
tensorflow-hub-0.12.0
Downgarde tensorflow-estimator to 2.4.0
Answered By - TFer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.