diff --git a/core/trainers/framework/runner.py b/core/trainers/framework/runner.py index e1b89312fc1ed0ae8f05f2306b14b99b55a82512..61cecc7f01adc24e8f1ca54a505496f22daabcfa 100644 --- a/core/trainers/framework/runner.py +++ b/core/trainers/framework/runner.py @@ -395,17 +395,22 @@ class PSRunner(RunnerBase): end_time = time.time() seconds = end_time - begin_time message = "epoch {} done, use time: {}".format(epoch, seconds) - metrics_result = [] - for key in metrics: - if isinstance(metrics[key], Metric): - _str = metrics[key].cal_global_metrics( - context["fleet"], - context["model"][model_dict["name"]]["scope"]) - elif result is not None: - _str = "{}={}".format(key, result[key]) - metrics_result.append(_str) - if len(metrics_result) > 0: - message += ", global metrics: " + ", ".join(metrics_result) + + # TODO, wait for PaddleCloudRoleMaker supports gloo + from paddle.fluid.incubate.fleet.base.role_maker import GeneralRoleMaker + if context["fleet"] is not None and isinstance(context["fleet"], + GeneralRoleMaker): + metrics_result = [] + for key in metrics: + if isinstance(metrics[key], Metric): + _str = metrics[key].cal_global_metrics( + context["fleet"], + context["model"][model_dict["name"]]["scope"]) + elif result is not None: + _str = "{}={}".format(key, result[key]) + metrics_result.append(_str) + if len(metrics_result) > 0: + message += ", global metrics: " + ", ".join(metrics_result) print(message) with fluid.scope_guard(context["model"][model_dict["name"]][ "scope"]):