xgboost/src/common/common.cu
Rong Ou 38ab79f889 Make HostDeviceVector single gpu only (#4773)
* Make HostDeviceVector single gpu only
2019-08-26 09:51:13 +12:00

23 lines
438 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 &except) {
return 0;
}
return n_visgpus;
}
} // namespace common
} // namespace xgboost