diff --git a/paddle/fluid/framework/fleet/box_wrapper.cc b/paddle/fluid/framework/fleet/box_wrapper.cc index 9d894d2ef38cab7e4ca71258b2e865a6ae11f334..344565da94006d59b1a404cea0ccff268901d937 100644 --- a/paddle/fluid/framework/fleet/box_wrapper.cc +++ b/paddle/fluid/framework/fleet/box_wrapper.cc @@ -118,6 +118,10 @@ void BoxWrapper::BeginPass() const { "BeginPass failed in BoxPS.")); } +void BoxWrapper::SetTestMode(bool is_test) const { + boxps_ptr_->SetTestMode(is_test); +} + void BoxWrapper::EndPass(bool need_save_delta) const { int ret = boxps_ptr_->EndPass(need_save_delta); PADDLE_ENFORCE_EQ( diff --git a/paddle/fluid/framework/fleet/box_wrapper.h b/paddle/fluid/framework/fleet/box_wrapper.h index 8f4eebd7c07386906fd70811f79973d1208732ee..6f4a0bf082fa8215d11af70ba0e3e98246c80fc5 100644 --- a/paddle/fluid/framework/fleet/box_wrapper.h +++ b/paddle/fluid/framework/fleet/box_wrapper.h @@ -44,6 +44,8 @@ limitations under the License. */ #include "paddle/fluid/string/string_helper.h" #define BUF_SIZE 1024 * 1024 +extern void comlog_set_log_level(int log_level); +extern int com_logstatus(); namespace paddle { namespace framework { @@ -167,9 +169,11 @@ class AfsManager { _afshandler = new afs::AfsFileSystem(fs_name.c_str(), user.c_str(), pwd.c_str(), conf_path.c_str()); VLOG(0) << "AFSAPI Init: user: " << user << ", pwd: " << pwd; - int ret = _afshandler->Init(true, true); + int ret = _afshandler->Init(true, (com_logstatus() == 0)); PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( "Called AFSAPI Init Interface Failed.")); + // Too high level will hurt the performance + comlog_set_log_level(4); ret = _afshandler->Connect(); PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( "Called AFSAPI Connect Interface Failed")); @@ -334,6 +338,7 @@ class BoxWrapper { void EndFeedPass(boxps::PSAgentBase* agent) const; void BeginPass() const; void EndPass(bool need_save_delta) const; + void SetTestMode(bool is_test) const; void PullSparse(const paddle::platform::Place& place, const std::vector& keys, const std::vector& values, diff --git a/paddle/fluid/pybind/box_helper_py.cc b/paddle/fluid/pybind/box_helper_py.cc index c2b6a73bbd4b821725b3d8ddb54b58b08110e4ba..d5a33075e6790b573d26914883b032d5d9823fec 100644 --- a/paddle/fluid/pybind/box_helper_py.cc +++ b/paddle/fluid/pybind/box_helper_py.cc @@ -69,6 +69,8 @@ void BindBoxWrapper(py::module* m) { py::call_guard()) .def("feed_pass", &framework::BoxWrapper::FeedPass, py::call_guard()) + .def("set_test_mode", &framework::BoxWrapper::SetTestMode, + py::call_guard()) .def("save_delta", &framework::BoxWrapper::SaveDelta, py::call_guard()) .def("initialize_gpu", &framework::BoxWrapper::InitializeGPU,