diff --git a/src/transformers/trainer_utils.py b/src/transformers/trainer_utils.py index bb44c4c1ab0..d6008b53e75 100644 --- a/src/transformers/trainer_utils.py +++ b/src/transformers/trainer_utils.py @@ -350,6 +350,8 @@ def speed_metrics(split, start_time, num_samples=None, num_steps=None): """ runtime = time.time() - start_time result = {f"{split}_runtime": round(runtime, 4)} + if runtime == 0: + return result if num_samples is not None: samples_per_second = num_samples / runtime result[f"{split}_samples_per_second"] = round(samples_per_second, 3)