From 3afb841105490b3d7009637314f7c7ce1ef52d27 Mon Sep 17 00:00:00 2001 From: xiexionghang Date: Thu, 12 Sep 2019 10:25:20 +0800 Subject: [PATCH] fix epoch_done save --- .../custom_trainer/feed/accessor/epoch_accessor.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc b/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc index cd73f918..1773c056 100755 --- a/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc +++ b/paddle/fluid/train/custom_trainer/feed/accessor/epoch_accessor.cc @@ -49,11 +49,15 @@ namespace feed { set_status(EpochStatusFiled::CheckpointPathField, _last_checkpoint_path); set_status(EpochStatusFiled::DateField, format_timestamp(epoch_id, "%Y%m%d-%H%M")); set_status(EpochStatusFiled::InferenceBaseKeyField, _inference_base_model_key); - if (epoch_id > _last_done_epoch_id) { - // 保留末尾1000数据 - auto fs = _trainer_context->file_system.get(); - std::string done_str = paddle::string::join_strings(_done_status, '\t'); - fs->append_line(_done_file_path, done_str, 1000); + + auto* env = _trainer_context->environment.get(); + if (env->is_master_node(EnvironmentRole::WORKER)) { + if (epoch_id > _last_done_epoch_id) { + // 保留末尾1000数据 + auto fs = _trainer_context->file_system.get(); + std::string done_str = paddle::string::join_strings(_done_status, '\t'); + fs->append_line(_done_file_path, done_str, 1000); + } } return 0; } -- GitLab