Fix specifying gpu_id, add tests. (#3851)
* Rewrite gpu_id related code. * Remove normalised/unnormalised operatios. * Address difference between `Index' and `Device ID'. * Modify doc for `gpu_id'. * Better LOG for GPUSet. * Check specified n_gpus. * Remove inappropriate `device_idx' term. * Clarify GpuIdType and size_t.
This commit is contained in:
@@ -38,7 +38,7 @@ class HingeObj : public ObjFunction {
|
||||
void Configure(
|
||||
const std::vector<std::pair<std::string, std::string> > &args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
devices_ = GPUSet::All(param_.n_gpus).Normalised(param_.gpu_id);
|
||||
devices_ = GPUSet::All(param_.gpu_id, param_.n_gpus);
|
||||
label_correct_.Resize(devices_.IsEmpty() ? 1 : devices_.Size());
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class SoftmaxMultiClassObj : public ObjFunction {
|
||||
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
CHECK(param_.n_gpus != 0) << "Must have at least one device"; // Default is -1
|
||||
devices_ = GPUSet::All(param_.n_gpus).Normalised(param_.gpu_id);
|
||||
devices_ = GPUSet::All(param_.gpu_id, param_.n_gpus);
|
||||
label_correct_.Resize(devices_.IsEmpty() ? 1 : devices_.Size());
|
||||
}
|
||||
void GetGradient(const HostDeviceVector<bst_float>& preds,
|
||||
|
||||
@@ -54,7 +54,7 @@ class RegLossObj : public ObjFunction {
|
||||
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
CHECK(param_.n_gpus != 0) << "Must have at least one device"; // Default is -1
|
||||
devices_ = GPUSet::All(param_.n_gpus).Normalised(param_.gpu_id);
|
||||
devices_ = GPUSet::All(param_.gpu_id, param_.n_gpus);
|
||||
label_correct_.Resize(devices_.IsEmpty() ? 1 : devices_.Size());
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class PoissonRegression : public ObjFunction {
|
||||
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
CHECK(param_.n_gpus != 0) << "Must have at least one device"; // Default is -1
|
||||
devices_ = GPUSet::All(param_.n_gpus).Normalised(param_.gpu_id);
|
||||
devices_ = GPUSet::All(param_.gpu_id, param_.n_gpus);
|
||||
label_correct_.Resize(devices_.IsEmpty() ? 1 : devices_.Size());
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ class GammaRegression : public ObjFunction {
|
||||
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
CHECK(param_.n_gpus != 0) << "Must have at least one device"; // Default is -1
|
||||
devices_ = GPUSet::All(param_.n_gpus).Normalised(param_.gpu_id);
|
||||
devices_ = GPUSet::All(param_.gpu_id, param_.n_gpus);
|
||||
label_correct_.Resize(devices_.IsEmpty() ? 1 : devices_.Size());
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ class TweedieRegression : public ObjFunction {
|
||||
void Configure(const std::vector<std::pair<std::string, std::string> >& args) override {
|
||||
param_.InitAllowUnknown(args);
|
||||
CHECK(param_.n_gpus != 0) << "Must have at least one device"; // Default is -1
|
||||
devices_ = GPUSet::All(param_.n_gpus).Normalised(param_.gpu_id);
|
||||
devices_ = GPUSet::All(param_.gpu_id, param_.n_gpus);
|
||||
label_correct_.Resize(devices_.IsEmpty() ? 1 : devices_.Size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user