xgboost
generic_parameters.h
Go to the documentation of this file.
1 
5 #ifndef XGBOOST_GENERIC_PARAMETERS_H_
6 #define XGBOOST_GENERIC_PARAMETERS_H_
7 
8 #include <xgboost/logging.h>
9 #include <xgboost/parameter.h>
10 
11 #include <string>
12 
13 namespace xgboost {
14 struct GenericParameter : public XGBoostParameter<GenericParameter> {
15  // Constant representing the device ID of CPU.
16  static int32_t constexpr kCpuId = -1;
17 
18  public:
19  // stored random seed
20  int64_t seed;
21  // whether seed the PRNG each iteration
23  // number of threads to use if OpenMP is enabled
24  // if equals 0, use system default
25  int nthread;
26  // primary device, -1 means no gpu.
27  int gpu_id;
28  // gpu page size in external memory mode, 0 means using the default.
29  size_t gpu_page_size;
31  bool validate_parameters {false};
32 
33  void CheckDeprecated() {
34  if (this->n_gpus != 0) {
35  LOG(WARNING)
36  << "\nn_gpus: "
37  << this->__MANAGER__()->Find("n_gpus")->GetFieldInfo().description;
38  }
39  }
45  void ConfigureGpuId(bool require_gpu);
46 
47  // declare parameters
49  DMLC_DECLARE_FIELD(seed).set_default(0).describe(
50  "Random number seed during training.");
51  DMLC_DECLARE_ALIAS(seed, random_state);
52  DMLC_DECLARE_FIELD(seed_per_iteration)
53  .set_default(false)
54  .describe(
55  "Seed PRNG determnisticly via iterator number, "
56  "this option will be switched on automatically on distributed "
57  "mode.");
58  DMLC_DECLARE_FIELD(nthread).set_default(0).describe(
59  "Number of threads to use.");
60  DMLC_DECLARE_ALIAS(nthread, n_jobs);
61 
62  DMLC_DECLARE_FIELD(gpu_id)
63  .set_default(-1)
64  .set_lower_bound(-1)
65  .describe("The primary GPU device ordinal.");
66  DMLC_DECLARE_FIELD(gpu_page_size)
67  .set_default(0)
68  .set_lower_bound(0)
69  .describe("GPU page size when running in external memory mode.");
70  DMLC_DECLARE_FIELD(enable_experimental_json_serialization)
71  .set_default(false)
72  .describe("Enable using JSON for memory serialization (Python Pickle, "
73  "rabit checkpoints etc.).");
74  DMLC_DECLARE_FIELD(validate_parameters)
75  .set_default(false)
76  .describe("Enable checking whether parameters are used or not.");
77  DMLC_DECLARE_FIELD(n_gpus)
78  .set_default(0)
79  .set_range(0, 1)
80  .describe(
81 "\n\tDeprecated. Single process multi-GPU training is no longer supported."
82 "\n\tPlease switch to distributed training with one process per GPU."
83 "\n\tThis can be done using Dask or Spark. See documentation for details.");
84  }
85 
86  private:
87  // number of devices to use (deprecated).
88  int n_gpus {0}; // NOLINT
89 };
90 } // namespace xgboost
91 
92 #endif // XGBOOST_GENERIC_PARAMETERS_H_
int gpu_id
Definition: generic_parameters.h:27
int64_t seed
Definition: generic_parameters.h:20
static int32_t constexpr kCpuId
Definition: generic_parameters.h:16
Definition: parameter.h:84
Definition: generic_parameters.h:14
void CheckDeprecated()
Definition: generic_parameters.h:33
bool enable_experimental_json_serialization
Definition: generic_parameters.h:30
void ConfigureGpuId(bool require_gpu)
Configure the parameter `gpu_id&#39;.
DMLC_DECLARE_PARAMETER(GenericParameter)
Definition: generic_parameters.h:48
namespace of xgboost
Definition: base.h:102
size_t gpu_page_size
Definition: generic_parameters.h:29
bool validate_parameters
Definition: generic_parameters.h:31
macro for using C++11 enum class as DMLC parameter
bool seed_per_iteration
Definition: generic_parameters.h:22
int nthread
Definition: generic_parameters.h:25