-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling model including hub.KerasLayer fails in distribution strategy scope. #469
Comments
Yes, this may well be due to a bug in TensorFlow 2.0. Sorry about that. Please try a recent tf-nightly PIP package and reopen if the issue persists. |
Also, you're using a TF1-style hub.Module. Try https://tfhub.dev/tensorflow/bert_en_cased_L-12_H-768_A-12/1 instead (see https://www.tensorflow.org/hub/tf1_hub_module vs https://www.tensorflow.org/hub/tf2_saved_model). |
Edit: Apparently
This is the code for creating the strategy: TPU_ADDRESS = "grpc://" + "10.0.0.2:8470"
with tf.compat.v1.Session(TPU_ADDRESS) as session:
print('TPU devices:')
pprint.pprint(session.list_devices())
resolver = tf.distribute.cluster_resolver.TPUClusterResolver(TPU_ADDRESS)
tf.config.experimental_connect_to_host(resolver.master())
tf.tpu.experimental.initialize_tpu_system(resolver)
tpu_strategy = tf.distribute.experimental.TPUStrategy(resolver) So it looks like there might be a bug in TensorFlow 2.1? Or should I be creating the TPU distribution strategy differently? |
Please help me investigate further. Do I guess correctly that your code runs on a Colab notebook hosted on colab.research.google.com? Please share a Colab notebook with me to reproduce the issue with TF 2.1 (possibly prerelease) and BERT from a TF2-style SavedModel, such as https://tfhub.dev/tensorflow/bert_en_cased_L-12_H-768_A-12/1. |
@arnoegw I'm using Colab and a Google Cloud TPU Instance. The error I previously posted appears to be caused by |
Using TF-2.3, still got the same problem. I use distribute.MirroredStrategy().scope(). Any idea? |
I also have the same issue. Please help! |
FWIW, https://www.tensorflow.org/tutorials/text/solve_glue_tasks_using_bert_on_tpu shows how it works for TF2.4. (It also worked for TF2.3, but in Colab you can't change the TPU worker version to try.) |
I get an error when I want to compile my model.
Then later, in one section of my code, I want to train my model, but I get the following error.
|
Update: `[MirroredVariable:{ |
Why is this issue closed? Is there a solution?? |
When trying to compile a model that includes a
hub.KerasLayer
I get the following error:Code used to build and compile model:
This is the model I'm loading in the KerasLayer: https://tfhub.dev/google/bert_multi_cased_L-12_H-768_A-12/1
The entire model is created within the scope of the distribution strategy, so I'm not sure what the cause of the error would be, other than a bug.
The text was updated successfully, but these errors were encountered: