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:
@@ -1,5 +1,9 @@
|
||||
#include "../../../src/common/common.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/logging.h>
|
||||
#include "../../../src/common/common.h"
|
||||
#include "../helpers.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
@@ -36,6 +40,23 @@ TEST(GPUSet, GPUBasic) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GPUSet, Verbose) {
|
||||
{
|
||||
std::map<std::string, std::string> args {};
|
||||
args["verbosity"] = "3"; // LOG INFO
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
ConsoleLogger::Configure(args.cbegin(), args.cend());
|
||||
GPUSet::All(0, 1);
|
||||
std::string output = testing::internal::GetCapturedStderr();
|
||||
ASSERT_NE(output.find("GPU ID: 0"), std::string::npos);
|
||||
ASSERT_NE(output.find("GPUs: 1"), std::string::npos);
|
||||
|
||||
args["verbosity"] = "1"; // restore
|
||||
ConsoleLogger::Configure(args.cbegin(), args.cend());
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(XGBOOST_USE_NCCL)
|
||||
TEST(GPUSet, MGPU_GPUBasic) {
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <thrust/device_vector.h>
|
||||
#include <xgboost/base.h>
|
||||
#include "../../../src/common/device_helpers.cuh"
|
||||
#include "../helpers.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using xgboost::common::Span;
|
||||
@@ -65,7 +66,9 @@ void TestLbs() {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(cub_lbs, Test) { TestLbs(); }
|
||||
TEST(cub_lbs, Test) {
|
||||
TestLbs();
|
||||
}
|
||||
|
||||
TEST(sumReduce, Test) {
|
||||
thrust::device_vector<float> data(100, 1.0f);
|
||||
@@ -89,4 +92,6 @@ void TestAllocator() {
|
||||
}
|
||||
|
||||
// Define the test in a function so we can use device lambda
|
||||
TEST(bulkAllocator, Test) { TestAllocator(); }
|
||||
TEST(bulkAllocator, Test) {
|
||||
TestAllocator();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../../../src/common/enum_class_param.h"
|
||||
#include <dmlc/parameter.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/enum_class_param.h>
|
||||
|
||||
enum class Foo : int {
|
||||
kBar = 0, kFrog = 1, kCat = 2, kDog = 3
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "../../../src/common/device_helpers.cuh"
|
||||
#include "../../../src/common/hist_util.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "xgboost/c_api.h"
|
||||
#include <algorithm>
|
||||
@@ -7,6 +5,10 @@
|
||||
#include <thrust/device_vector.h>
|
||||
#include <thrust/iterator/counting_iterator.h>
|
||||
|
||||
#include "../helpers.h"
|
||||
#include "../../../src/common/device_helpers.cuh"
|
||||
#include "../../../src/common/hist_util.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
@@ -27,8 +29,6 @@ void TestDeviceSketch(const GPUSet& devices) {
|
||||
// parameters for finding quantiles
|
||||
tree::TrainParam p;
|
||||
p.max_bin = 20;
|
||||
p.gpu_id = 0;
|
||||
p.n_gpus = devices.Size();
|
||||
// ensure that the exact quantiles are found
|
||||
int gpu_batch_nrows = nrows * 10;
|
||||
|
||||
@@ -39,7 +39,7 @@ void TestDeviceSketch(const GPUSet& devices) {
|
||||
// find the cuts on the GPU
|
||||
const SparsePage& batch = *(*dmat)->GetRowBatches().begin();
|
||||
HistCutMatrix hmat_gpu;
|
||||
DeviceSketch(batch, (*dmat)->Info(), p, &hmat_gpu, gpu_batch_nrows);
|
||||
DeviceSketch(batch, (*dmat)->Info(), p, &hmat_gpu, gpu_batch_nrows, devices);
|
||||
|
||||
// compare the cuts
|
||||
double eps = 1e-2;
|
||||
|
||||
Reference in New Issue
Block a user