tensorflow / tensor2tensor

Library of deep learning models and datasets designed to make deep learning more accessible and accelerate ML research.
Apache License 2.0
15.57k stars 3.51k forks source link

Error using `t2t-trainer` command #1729

Open jesusdelpeso opened 5 years ago

jesusdelpeso commented 5 years ago

Description

The t2t-trainer command fails to run.

Environment information

Google Colab environment.

In fact, you can just reproduce this problem merely by executing the notebook https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/notebooks/Transformer_translate.ipynb in Colab.

OS: 
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"

Kernel version: 4.14.137+

$ pip freeze | grep tensor
mesh-tensorflow==0.1.4
tensor2tensor==1.14.1
tensorboard==1.15.0
tensorboardcolab==0.0.22
tensorflow==1.15.0
tensorflow-datasets==1.3.0
tensorflow-estimator==1.15.1
tensorflow-gan==2.0.0
tensorflow-hub==0.6.0
tensorflow-metadata==0.15.0
tensorflow-privacy==0.2.1
tensorflow-probability==0.7.0

$ python -V
Python 3.6.8

For bugs: reproduction and error logs

# Steps to reproduce:
Just execute the https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/notebooks/Transformer_translate.ipynb notebook in Colab.

In particular, any call to t2t-trainer command.
# Error logs:

WARNING: Logging before flag parsing goes to stderr.
W1028 17:35:39.856756 140567286806400 module_wrapper.py:139] From /usr/local/lib/python2.7/dist-packages/tensor2tensor/utils/expert_utils.py:68: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W1028 17:35:39.986994 140567286806400 lazy_loader.py:50] 
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

W1028 17:35:41.956151 140567286806400 module_wrapper.py:139] From /usr/local/lib/python2.7/dist-packages/tensor2tensor/utils/adafactor.py:27: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

W1028 17:35:41.956594 140567286806400 module_wrapper.py:139] From /usr/local/lib/python2.7/dist-packages/tensor2tensor/utils/multistep_optimizer.py:32: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.

W1028 17:35:41.969721 140567286806400 module_wrapper.py:139] From /usr/local/lib/python2.7/dist-packages/mesh_tensorflow/ops.py:4237: The name tf.train.CheckpointSaverListener is deprecated. Please use tf.estimator.CheckpointSaverListener instead.

W1028 17:35:41.970010 140567286806400 module_wrapper.py:139] From /usr/local/lib/python2.7/dist-packages/mesh_tensorflow/ops.py:4260: The name tf.train.SessionRunHook is deprecated. Please use tf.estimator.SessionRunHook instead.

W1028 17:35:42.014368 140567286806400 module_wrapper.py:139] From /usr/local/lib/python2.7/dist-packages/tensor2tensor/utils/trainer_lib.py:105: The name tf.OptimizerOptions is deprecated. Please use tf.compat.v1.OptimizerOptions instead.

Traceback (most recent call last):
  File "/usr/local/bin/t2t-trainer", line 23, in <module>
    from tensor2tensor.bin import t2t_trainer
  File "/usr/local/lib/python2.7/dist-packages/tensor2tensor/bin/t2t_trainer.py", line 25, in <module>
    from tensor2tensor import models  # pylint: disable=unused-import
  File "/usr/local/lib/python2.7/dist-packages/tensor2tensor/models/__init__.py", line 70, in <module>
    from tensor2tensor.models.video import savp
  File "/usr/local/lib/python2.7/dist-packages/tensor2tensor/models/video/savp.py", line 36, in <module>
    gan_losses = tf.contrib.gan.losses.wargs
  File "/usr/local/lib/python2.7/dist-packages/tensorflow_core/python/util/lazy_loader.py", line 63, in __getattr__
    return getattr(module, item)
AttributeError: 'module' object has no attribute 'gan'
Andrea-moscatelli commented 5 years ago

same error

Gerzer commented 5 years ago

I'm having this issue as well.

patrickphat commented 5 years ago

I'm having this issue too.

patrickphat commented 5 years ago

I fixed the problem by installing 1.13.4 version of tensor2tensor !pip install tensor2tensor==1.13.4

Gerzer commented 5 years ago

I fixed the problem by installing 1.13.4 version of tensor2tensor !pip install tensor2tensor==1.13.4

!pip install tensor2tensor==1.14.0 seems to work as well. I think that the problem is with version 1.14.1, which is both the latest version and the one that's preinstalled on Colaboratory.

creatist commented 4 years ago

I fixed the problem by installing 1.15.0 version of tensor2tensor.

mesh-tensorflow==0.1.6 tensor2tensor==1.15.0 tensorboard==1.15.0 tensorboard-logger==0.1.0 tensorboardX==1.8 tensorflow-datasets==1.3.0 tensorflow-estimator==1.15.1 tensorflow-gan==2.0.0 tensorflow-gpu==1.15.0 tensorflow-hub==0.7.0 tensorflow-metadata==0.15.1 tensorflow-probability==0.7.0

skr3178 commented 2 years ago

Same setup as above gives error:


AttributeError Traceback (most recent call last) in () 10 USR_DIR = os.path.expanduser("/t2t/user") # This folder contains our data that we want to add 11 ---> 12 tf.gfile.MakeDirs(DATA_DIR) 13 tf.gfile.MakeDirs(TMP_DIR) 14 tf.gfile.MakeDirs(TRAIN_DIR)

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

`import tensorflow as tf import os

DATA_DIR = os.path.expanduser("/t2t/data") # This folder contain the data TMP_DIR = os.path.expanduser("/t2t/tmp") TRAIN_DIR = os.path.expanduser("/t2t/train") # This folder contain the model EXPORT_DIR = os.path.expanduser("/t2t/export") # This folder contain the exported model for production TRANSLATIONS_DIR = os.path.expanduser("/t2t/translation") # This folder contain all translated sequence EVENT_DIR = os.path.expanduser("/t2t/event") # Test the BLEU score USR_DIR = os.path.expanduser("/t2t/user") # This folder contains our data that we want to add

tf.gfile.MakeDirs(DATA_DIR) tf.gfile.MakeDirs(TMP_DIR) tf.gfile.MakeDirs(TRAIN_DIR) tf.gfile.MakeDirs(EXPORT_DIR) tf.gfile.MakeDirs(TRANSLATIONS_DIR) tf.gfile.MakeDirs(EVENT_DIR) tf.gfile.MakeDirs(USR_DIR)`