You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
8 years ago
|
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||
9 years ago
|
|
||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
you may not use this file except in compliance with the License.
|
||
|
You may obtain a copy of the License at
|
||
|
|
||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
||
|
Unless required by applicable law or agreed to in writing, software
|
||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
See the License for the specific language governing permissions and
|
||
|
limitations under the License. */
|
||
|
|
||
|
#include <fenv.h>
|
||
7 years ago
|
#include "paddle/legacy/pserver/ParameterServerController.h"
|
||
9 years ago
|
#include "paddle/utils/PythonUtil.h"
|
||
|
|
||
|
#include "ParamUtil.h"
|
||
|
#include "Trainer.h"
|
||
|
|
||
8 years ago
|
DEFINE_bool(start_pserver, false, "Whether to start pserver");
|
||
|
DECLARE_int32(gpu_id);
|
||
|
DEFINE_string(job, "train", "one of (train, test, checkgrad)");
|
||
|
DECLARE_int32(start_pass);
|
||
|
DECLARE_string(config);
|
||
|
DECLARE_string(init_model_path);
|
||
|
DECLARE_string(rdma_tcp);
|
||
9 years ago
|
|
||
|
using namespace paddle; // NOLINT
|
||
|
|
||
|
int main(int argc, char** argv) {
|
||
8 years ago
|
// write logs instantly (never buffer log messages)
|
||
9 years ago
|
FLAGS_logbuflevel = -1;
|
||
8 years ago
|
|
||
9 years ago
|
initMain(argc, argv);
|
||
|
initPython(argc, argv);
|
||
|
|
||
8 years ago
|
std::unique_ptr<ParameterServerController> parameterServerPtr(nullptr);
|
||
9 years ago
|
if (FLAGS_start_pserver) {
|
||
8 years ago
|
parameterServerPtr.reset(
|
||
|
paddle::ParameterServerController::createFromGflags());
|
||
|
parameterServerPtr->start();
|
||
9 years ago
|
}
|
||
|
Trainer trainer;
|
||
|
auto config = TrainerConfigHelper::createFromFlags();
|
||
|
CHECK(config != nullptr) << "no valid config";
|
||
|
|
||
|
feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
|
||
|
trainer.init(config, FLAGS_job == "test");
|
||
|
|
||
|
if (FLAGS_job == "train") {
|
||
|
trainer.train();
|
||
|
} else if (FLAGS_job == "checkgrad") {
|
||
|
trainer.checkGradient();
|
||
|
} else if (FLAGS_job == "test") {
|
||
|
trainer.test();
|
||
8 years ago
|
} else if (FLAGS_job == "time") {
|
||
|
trainer.time();
|
||
9 years ago
|
} else {
|
||
|
LOG(FATAL) << "Unknown job type: " << FLAGS_job;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|