This PR changes base_margin into a 3-dim array, with one of them being reserved for multi-target classification. Also, a breaking change is made for binary serialization due to extra dimension along with a fix for saving the feature weights. Lastly, it unifies the prediction initialization between CPU and GPU. After this PR, the meta info setter in Python will be based on array interface.
24 lines
474 B
Plaintext
24 lines
474 B
Plaintext
/*!
|
|
* Copyright 2018 XGBoost contributors
|
|
*/
|
|
#include "common.h"
|
|
|
|
namespace xgboost {
|
|
namespace common {
|
|
|
|
int AllVisibleGPUs() {
|
|
int n_visgpus = 0;
|
|
try {
|
|
// When compiled with CUDA but running on CPU only device,
|
|
// cudaGetDeviceCount will fail.
|
|
dh::safe_cuda(cudaGetDeviceCount(&n_visgpus));
|
|
} catch (const dmlc::Error &) {
|
|
cudaGetLastError(); // reset error.
|
|
return 0;
|
|
}
|
|
return n_visgpus;
|
|
}
|
|
|
|
} // namespace common
|
|
} // namespace xgboost
|