From 66520f8b41768fdb3ef61cb9c5c0302c3bd39300 Mon Sep 17 00:00:00 2001 From: xuwei06 Date: Wed, 30 Nov 2016 22:16:35 -0800 Subject: [PATCH] Fix --job=test When the define_py_data_sources2 has both train_list and test_list, for job=test, the trainer will create both dataProvider_ and testDataProvider_. But dataProvider_ is not used. This causes SIGSEGV at finishAsync() because asyncLoader_ is not created. Change-Id: If579f715f80a70ebc795094792c3436bfa0f5746 --- paddle/gserver/dataproviders/DataProvider.h | 4 +++- paddle/trainer/Trainer.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/gserver/dataproviders/DataProvider.h b/paddle/gserver/dataproviders/DataProvider.h index 8b7fb27f821..8247693822a 100644 --- a/paddle/gserver/dataproviders/DataProvider.h +++ b/paddle/gserver/dataproviders/DataProvider.h @@ -271,7 +271,9 @@ public: void finishAsyncLoad() { stopping_ = true; taskReadySem_.post(); - asyncLoader_->join(); + if (asyncLoader_) { + asyncLoader_->join(); + } } void setPending(bool pending) { pending_ = pending; } diff --git a/paddle/trainer/Trainer.cpp b/paddle/trainer/Trainer.cpp index 8a5162912e5..a361386b902 100644 --- a/paddle/trainer/Trainer.cpp +++ b/paddle/trainer/Trainer.cpp @@ -205,7 +205,7 @@ void Trainer::init(const std::shared_ptr& config, (!IGradientMachineMode::dataMustInCpu(mode_, FLAGS_trainer_count)); dataProvider_ = dataProvider; - if (!dataProvider_ && config_->hasDataConfig()) { + if (!dataProvider_ && config_->hasDataConfig() && !testing_) { dataProvider_.reset(DataProvider::create(*config_, *config_, gpuData)); } if (!testDataProvider_) { -- GitLab