De-duplicate GPU parameters. (#4454)

* Only define `gpu_id` and `n_gpus` in `LearnerTrainParam`
* Pass LearnerTrainParam through XGBoost vid factory method.
* Disable all GPU usage when GPU related parameters are not specified (fixes XGBoost choosing GPU over aggressively).
* Test learner train param io.
* Fix gpu pickling.
This commit is contained in:
Jiaming Yuan
2019-05-29 11:55:57 +08:00
committed by GitHub
parent a3fedbeaa8
commit c589eff941
69 changed files with 927 additions and 562 deletions

View File

@@ -7,9 +7,10 @@
TEST(Linear, shotgun) {
auto mat = xgboost::CreateDMatrix(10, 10, 0);
auto lparam = xgboost::CreateEmptyGenericParam(0, 0);
{
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
xgboost::LinearUpdater::Create("shotgun"));
xgboost::LinearUpdater::Create("shotgun", &lparam));
updater->Init({{"eta", "1."}});
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
(*mat)->Info().num_row_, xgboost::GradientPair(-5, 1.0));
@@ -24,7 +25,7 @@ TEST(Linear, shotgun) {
}
{
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
xgboost::LinearUpdater::Create("shotgun"));
xgboost::LinearUpdater::Create("shotgun", &lparam));
EXPECT_ANY_THROW(updater->Init({{"feature_selector", "random"}}));
}
delete mat;
@@ -32,8 +33,9 @@ TEST(Linear, shotgun) {
TEST(Linear, coordinate) {
auto mat = xgboost::CreateDMatrix(10, 10, 0);
auto lparam = xgboost::CreateEmptyGenericParam(0, 0);
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
xgboost::LinearUpdater::Create("coord_descent"));
xgboost::LinearUpdater::Create("coord_descent", &lparam));
updater->Init({{"eta", "1."}});
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
(*mat)->Info().num_row_, xgboost::GradientPair(-5, 1.0));