google-research / albert

ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
Apache License 2.0
3.24k stars 569 forks source link

tensorflow_estimator version incompatibility? #140

Closed evezhier closed 4 years ago

evezhier commented 4 years ago

With all the dependencies installed from requirements.txt with pip when executing run_pretraining.py as the readme suggests, an error occurs:

Traceback (most recent call last):  
    File "/home/xxx/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/xxx/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/media/xxx/yyy/albert/ALBERT/run_pretraining.py", line 23, in <module>
    import modeling
  File "/media/xxx/yyy/albert/ALBERT/modeling.py", line 34, in <module>
    from tensorflow.contrib import layers as contrib_layers
  File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 50, in __getattr__
    module = self._load()
  File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "/home/xxx/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow_core/contrib/__init__.py", line 48, in <module>
    from tensorflow.contrib import estimator
  File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow_core/contrib/estimator/__init__.py", line 30, in <module>
    from tensorflow_estimator.contrib import estimator
ModuleNotFoundError: No module named 'tensorflow_estimator.contrib'

The problem seems to occur due to TF/estimator version inconsistency, could you provide any guidance?

0x0539 commented 4 years ago

Can you confirm the TF version being used?

python3
import tensorflow
print(tensorflow.__version__)
evezhier commented 4 years ago

Screenshot from 2020-02-07 14-10-04

0x0539 commented 4 years ago

What if you try running the import statement from the console?

python3
import tensorflow
from tensorflow.contrib import estimator

Does it succeed or raise the same error?

evezhier commented 4 years ago

It raises the error. I've already tried pip-installing TFE 1.15.1, which is compatible with TF 1.15.2. Probably, some different version is required, as in https://github.com/tensorflow/tensorflow/issues/23163 In this case please update the requirements.

0x0539 commented 4 years ago

Did you install from requirements.txt? https://github.com/google-research/ALBERT/blob/master/requirements.txt has TF 1.15.2, which depends on tensorflow-estimator pip package.

I can't reproduce the issue in my own environment, so I'm not sure what, if anything, to fix. Can you try setting up a new virtualenv and only use requirements.txt?

evezhier commented 4 years ago

Checked it on another machine where TF was built from source, and it worked. Probably messed up conda or something. In any case, the issue is probably irrelevant, my bad. Thanks.