From 8e0bcb56ec5a3b09c4897fb8b4575079faf0b0c3 Mon Sep 17 00:00:00 2001 From: Qingqing Cao Date: Mon, 20 Jul 2020 17:54:08 -0400 Subject: [PATCH] DataParallel fix: multi gpu evaluation (#5926) The DataParallel training was fixed in https://github.com/huggingface/transformers/pull/5733, this commit also fixes the evaluation. It's more convenient when the user enables both `do_train` and `do_eval`. --- examples/question-answering/run_squad.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/question-answering/run_squad.py b/examples/question-answering/run_squad.py index 20b6c88922..fa11a33ca6 100644 --- a/examples/question-answering/run_squad.py +++ b/examples/question-answering/run_squad.py @@ -316,7 +316,8 @@ def evaluate(args, model, tokenizer, prefix=""): inputs.update( {"langs": (torch.ones(batch[0].shape, dtype=torch.int64) * args.lang_id).to(args.device)} ) - + if isinstance(model, torch.nn.DataParallel): + inputs["return_tuple"] = True outputs = model(**inputs) for i, feature_index in enumerate(feature_indices):