conflict between TF 2.0 and T2T 1.14.1

Skip to first unread message

Weiguang Guan

Oct 15, 2019, 7:51:50 PM10/15/19
to tensor2tensor
"pip list" shows  

-datasets                1.2.0
-estimator               2.0.0
-gan                     1.0.0.dev0
-gpu                     2.0.0
-metadata                0.15.0
-probability             0.7.0

When I run bert-multitask-learning, I got error message shown below:
Traceback (most recent call last):
File "", line 14, in <module>
from bert_multitask_learning import (get_or_make_label_encoder, FullTokenizer,
File "/lustre03/project/6007993/rrs99/code/bert-multitask-learning/bert_multitask_learning/", line 4, in <module>
from .model_fn import *
File "/lustre03/project/6007993/rrs99/code/bert-multitask-learning/bert_multitask_learning/", line 10, in <module>
from .top import (
File "/lustre03/project/6007993/rrs99/code/bert-multitask-learning/bert_multitask_learning/", line 9, in <module>
from .top_utils import (TopLayer, gather_indexes,
File "/lustre03/project/6007993/rrs99/code/bert-multitask-learning/bert_multitask_learning/", line 7, in <module>
from tensor2tensor.utils import metrics as t2t_metrics
File "/lustre03/project/6007993/rrs99/venvs/bert_multi/lib/python3.6/site-packages/tensor2tensor/utils/", line 25, in <module>
from tensor2tensor.layers import modalities
File "/lustre03/project/6007993/rrs99/venvs/bert_multi/lib/python3.6/site-packages/tensor2tensor/layers/", line 28, in <module>
from tensor2tensor.layers import common_attention
File "/lustre03/project/6007993/rrs99/venvs/bert_multi/lib/python3.6/site-packages/tensor2tensor/layers/", line 954, in <module>
def attention_bias_to_padding(attention_bias, cast_fn=tf.to_float):
AttributeError: module 'tensorflow' has no attribute 'to_float'

The error message tells me that TF doesn't have function to_float defined. To check it, I did the following experiment:
>>> import tensorflow as tf
>>> tf.to_float
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow' has no attribute 'to_float'

However, in my_virtualenv/lib/python3.6/site-packages/tensorflow_core/python/ops/, it DOES define to_float although it is deprecated:
@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
def to_float(x, name="ToFloat"):

Can anyone elaborate on this problem? Thanks a lot.


Sumeet Singh

Oct 17, 2019, 3:54:03 PM10/17/19
to tensor2tensor
I am facing the same problem. I suppose one could just stay on TF 1.15. However, I am looking to change the tensor2tensor code and so am wondering what the dependency requirements are for working on the tensor2tensor repo. (I don't think I should be installing the tensor2tensor package, since I'll be actively developing code within the repo)

Sumeet Singh

Oct 17, 2019, 4:46:48 PM10/17/19
to tensor2tensor
Forgot to mention that I am on Python 3. I suspect tensor2tensor works best with Python 2. (and by the way the there are no tensorflow 1.15 packages for python 3, but tensorflow_probability 0.8 requires min tensorflow v1.15).

Weiguang Guan

Oct 17, 2019, 7:31:39 PM10/17/19
to tensor2tensor
I actually installed TF 1.14 before installing T2T. However, I don't know why the installation of T2T triggers the installation of TF 2.0 even though 1.14 is there already. Thinking the latest version of T2T might depend on TF 2.0, I did another test --- installing TF 1.14 and T2T 1.13. Guess what -- it triggers the installation TF 2.0 again. 

What's even stranger to me is the fact installing T2T triggers the installation of TF 2.0 what is not compatible with T2T. Can someone explain it?


Paige Bailey

Oct 17, 2019, 7:44:13 PM10/17/19
to Weiguang Guan, Martin Wicke, tensor2tensor
Adding +Martin Wicke.

You received this message because you are subscribed to the Google Groups "tensor2tensor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit


Paige Bailey   

Product Manager (TensorFlow)



Lukasz Kaiser

Oct 17, 2019, 7:53:14 PM10/17/19
to Paige Bailey, Weiguang Guan, Martin Wicke, tensor2tensor
It looks like some recent changes in Mesh TF dependencies triggered this. We are investigating.


Sumeet Singh

Oct 21, 2019, 4:55:16 PM10/21/19
to tensor2tensor
Got it to work with Python 3.6 using pipenv --skip-lock. Pasting the pipfile for what its worth.

name = "pypi"
verify_ssl = true


tensorflow = "==1.15.*"
tensorflow-probability = "*"
scipy = "*"
requests = "*"
mesh-tensorflow = "*"
gym = "*"
pillow = "*"
tensorflow-gan = "*"
sympy = "*"
pypng = "*"
google-api-python-client = "*"
oauth2client = "*"
jupyter = "*"
matplotlib = "*"

python_version = "3.6"

allow_prereleases = true

On Tuesday, October 15, 2019 at 4:51:50 PM UTC-7, Weiguang Guan wrote:
Reply all
Reply to author
0 new messages