google-research / tapas

End-to-end neural table-text understanding models.
Apache License 2.0
1.14k stars 218 forks source link

Error: "tf.summary.FileWriter is not compatible with eager execution. Use tf.contrib.summary instead." #127

Closed Martin36 closed 3 years ago

Martin36 commented 3 years ago

I get the following error when running

python /tapas/experiments/table_retriever_experiment.py \ 
    --do_predict \
    --model_dir=tapas_models \
    --input_file_eval=data/tapas/tf_records/tf_examples/dev.tfrecord \
    --bert_config_file=tapas_dual_encoder_proj_256_tiny/bert_config.json \
    --init_from_single_encoder=false \
    --down_projection_dim=256 \
    --eval_batch_size=32 \
    --num_train_examples=65000 \
    --max_seq_length=512
tf.summary.FileWriter is not compatible with eager execution. Use tf.contrib.summary instead.
  File "/home/martin/FEVER2021_SharedTask/tapas/tapas/scripts/calc_metrics_utils.py", line 59, in write_to_tensorboard
    with tf.summary.FileWriter(logdir) as writer:
  File "/home/martin/FEVER2021_SharedTask/tapas/tapas/utils/experiment_utils.py", line 251, in save_metrics
    calc_metrics_utils.write_to_tensorboard(metrics, step,
  File "/home/martin/FEVER2021_SharedTask/tapas/tapas/experiments/table_retriever_experiment.py", line 169, in _predict_and_export_metrics
    experiment_utils.save_metrics(output_dir, mode, step, p_at_k)
  File "/home/martin/FEVER2021_SharedTask/tapas/tapas/experiments/table_retriever_experiment.py", line 300, in main
    _predict_and_export_metrics(
  File "/home/martin/FEVER2021_SharedTask/tapas/tapas/experiments/table_retriever_experiment.py", line 310, in <module>
    app.run(main)

Maybe I am running it in the wrong way, but what seems to fix this error is to put the line tf.disable_eager_execution() at the beginning of the calc_metrics_utils.py script (but after the import of tensorflow). However, I am not sure if this would destroy some intended functionality.

eisenjulian commented 3 years ago

Thanks for the report, what you suggest works and won't break any functionality, on the contrary! We will update table_retriever_experiment.py to add tf.disable_v2_behavior() at the top of the file which has a similar outcome.