tensor2tensor icon indicating copy to clipboard operation
tensor2tensor copied to clipboard

AttributeError: module 'tensorflow' has no attribute 'flags'

Open birdmw opened this issue 5 years ago • 10 comments

Description

C:\Users\XXXXX\Anaconda3\Lib\site-packages\tensor2tensor\bin>python t2t_trainer.py

Traceback (most recent call last):
  File "t2t_trainer.py", line 24, in <module>
    from tensor2tensor import models  # pylint: disable=unused-import
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\models\__init__.py", line 26, in <module>
    from tensor2tensor.models import basic
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\models\basic.py", line 25, in <module>
    from tensor2tensor.utils import t2t_model
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\utils\t2t_model.py", line 37, in <module>
    from tensor2tensor.utils import decoding
  File "C:\Users\XXXXX\Anaconda3\lib\site-packages\tensor2tensor\utils\decoding.py", line 41, in <module>
    FLAGS = tf.flags.FLAGS
AttributeError: module 'tensorflow' has no attribute 'flags'

Environment information

OS: Windows 10 - 64bit

$ pip freeze | grep tensor
tensor2tensor==1.15.2
tensorboard==2.0.1
tensorflow==2.0.0
tensorflow-datasets==1.3.0
tensorflow-estimator==2.0.1
tensorflow-gan==2.0.0
tensorflow-gpu==2.0.0
tensorflow-hub==0.7.0
tensorflow-metadata==0.15.1
tensorflow-probability==0.7.0
tf-estimator-nightly==2.0.0.dev2019111709
tf-nightly-gpu==2.1.0.dev20191117

$ python -V

Python 3.7.4

$ conda info

     active environment : None
       user config file : C:\Users\XXXX\.condarc
 populated config files :
          conda version : 4.7.12
    conda-build version : 3.18.9
         python version : 3.7.4.final.0
       virtual packages : __cuda=10.2
       base environment : C:\Users\XXXX\Anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\XXXX\Anaconda3\pkgs
                          C:\Users\XXXX\.conda\pkgs
                          C:\Users\XXXX\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\XXXX\Anaconda3\envs
                          C:\Users\XXXX\.conda\envs
                          C:\Users\XXXX\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Windows/10 Windows/10.0.17134
          administrator : False
             netrc file : None
           offline mode : False

Steps to reproduce:

With tensorflow-gpu-nightly installed on a win10 64 bit - simply navigate to \Anaconda3\Lib\site-packages\tensor2tensor\bin and type python t2t_{{any_file}}.py

Error logs:

  File "C:\Users\XXXX\Anaconda3\lib\site-packages\tensor2tensor\utils\decoding.py", line 41, in <module>
    FLAGS = tf.flags.FLAGS
AttributeError: module 'tensorflow' has no attribute 'flags'

birdmw avatar Nov 26 '19 01:11 birdmw

Maybe T2T doesn't support tensorflow2.0 yet.

Mr-wang2016 avatar Nov 26 '19 02:11 Mr-wang2016

tf.flags.FLAGS seems to have been moved to tf.compat.flags.Flag in tensorflow2.0

https://www.tensorflow.org/api_docs/python/tf/compat/v1/flags/Flag

RamoxCode avatar Dec 15 '19 20:12 RamoxCode

tf.flags.FLAGS seems to have been moved to tf.compat.flags.Flag in tensorflow2.0

https://www.tensorflow.org/api_docs/python/tf/compat/v1/flags/Flag

Seems like there's a 'v1' in it for TF 2.0: tf.compat.v1.flags.Flag

paklui avatar Jan 02 '20 23:01 paklui

i get this error in tf 1.13.1. what is the issue?

poojitharamachandra avatar Jan 27 '20 15:01 poojitharamachandra

i get this error in tf 1.13.1. what is the issue?

I had met same error in tf1.13 , have you solved this error?

ericosmic avatar Feb 13 '20 08:02 ericosmic

i get this error in tf 1.13.1. what is the issue?

I had met same error in tf1.13 , have you solved this error?

I had the same error in tf 1.13.1, and solved it by renaming my own module which has the same name with a site package (logging)

cszipper avatar Mar 13 '20 06:03 cszipper

I had some local (non-Conda) Tensorflow packages still installed, which were higher priority in the python environment

Just rm -r each tensorflow package in your ~/.local/ library and reinstall the conda environment.

sisrfeng avatar Feb 10 '21 09:02 sisrfeng

tf.compat.v1.flags.Flag Actually, it is FLAGS at the end to be precise in tf2

dave1996-13 avatar Mar 31 '21 21:03 dave1996-13

I had the same error did you solved this?

HaithemH avatar Oct 05 '22 08:10 HaithemH

tf.flags.FLAGS seems to have been moved to tf.compat.flags.Flag in tensorflow2.0

https://www.tensorflow.org/api_docs/python/tf/compat/v1/flags/Flag

Actually, it is tf.compat.v1.flags

Jeff-Winchell avatar Jun 30 '23 16:06 Jeff-Winchell