Skip to content
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

AttributeError: 'MirroredStrategy' object has no attribute 'experimental_run_v2' #5

Closed
theashworld opened this issue Jul 16, 2021 · 1 comment

Comments

@theashworld
Copy link

theashworld commented Jul 16, 2021

running the code as is in colab, I get this error:

Traceback (most recent call last):
  File "run_ust.py", line 147, in <module>
    train_model(max_seq_length, X_train, y_train, X_test, y_test, X_unlabeled, model_dir, tokenizer, sup_batch_size=sup_batch_size, unsup_batch_size=unsup_batch_size, unsup_size=unsup_size, sample_size=sample_size, TFModel=TFModel, Config=Config, pt_teacher_checkpoint=pt_teacher_checkpoint, sample_scheme=sample_scheme, T=T, alpha=alpha, valid_split=valid_split, sup_epochs=sup_epochs, unsup_epochs=unsup_epochs, N_base=N_base, dense_dropout=dense_dropout, attention_probs_dropout_prob=attention_probs_dropout_prob, hidden_dropout_prob=hidden_dropout_prob)
  File "/content/UST/ust.py", line 180, in train_model
    y_mean, y_var, y_pred, y_T = mc_dropout_evaluate(model, gpus, len(labels), X_unlabeled_sample, T=T)
  File "/content/UST/ust.py", line 59, in mc_dropout_evaluate
    pred = distributed_eval_step(batch)
  File "/content/UST/ust.py", line 56, in distributed_eval_step
    return strategy.experimental_run_v2(eval_step, args=(dataset_inputs,))
AttributeError: 'MirroredStrategy' object has no attribute 'experimental_run_v2'

tf version is 2.5.0 (provided by colab)

I tried changing the tf version to 1.x but in that case, I get

INFO:filelock:Lock 140358422112272 released on /root/.cache/huggingface/transformers/3c61d016573b14f7f008c02c4e51a366c67ab274726fe2910691e2a761acf43e.37395cee442ab11005bcd270f3c34464dc1704b715b5d7d52b1a461abe3b9e4e.lock
Traceback (most recent call last):
  File "run_ust.py", line 147, in <module>
    train_model(max_seq_length, X_train, y_train, X_test, y_test, X_unlabeled, model_dir, tokenizer, sup_batch_size=sup_batch_size, unsup_batch_size=unsup_batch_size, unsup_size=unsup_size, sample_size=sample_size, TFModel=TFModel, Config=Config, pt_teacher_checkpoint=pt_teacher_checkpoint, sample_scheme=sample_scheme, T=T, alpha=alpha, valid_split=valid_split, sup_epochs=sup_epochs, unsup_epochs=unsup_epochs, N_base=N_base, dense_dropout=dense_dropout, attention_probs_dropout_prob=attention_probs_dropout_prob, hidden_dropout_prob=hidden_dropout_prob)
  File "/content/UST/ust.py", line 113, in train_model
    model = models.construct_teacher(TFModel, Config, pt_teacher_checkpoint, max_seq_length, len(labels), dense_dropout=dense_dropout, attention_probs_dropout_prob=attention_probs_dropout_prob, hidden_dropout_prob=hidden_dropout_prob)
  File "/content/UST/models.py", line 20, in construct_teacher
    encoder = TFModel.from_pretrained(pt_teacher_checkpoint, config=config, from_pt=True, name="teacher")
  File "/usr/local/lib/python3.7/dist-packages/transformers/utils/dummy_tf_objects.py", line 404, in from_pretrained
    requires_backends(cls, ["tf"])
  File "/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py", line 612, in requires_backends
    raise ImportError("".join([BACKENDS_MAPPING[backend][1].format(name) for backend in backends]))
ImportError: 
TFBertModel requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the
installation page: https://www.tensorflow.org/install and follow the ones that match your environment.
@theashworld
Copy link
Author

my bad, requirements.txt to the rescue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant