[dask] Fix ddqdm with empty partition. (#7510)

* Fix empty partition.

* war.
This commit is contained in:
Jiaming Yuan
2021-12-16 20:37:29 +08:00
committed by GitHub
parent a512b4b394
commit 70b12d898a
8 changed files with 59 additions and 35 deletions

View File

@@ -16,8 +16,8 @@ namespace data {
// be supported in future. Does not currently support inferring row/column size
template <typename AdapterT>
SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
auto device =
adapter->DeviceIdx() < 0 ? dh::CurrentDevice() : adapter->DeviceIdx();
auto device = (adapter->DeviceIdx() < 0 || adapter->NumRows() == 0) ? dh::CurrentDevice()
: adapter->DeviceIdx();
CHECK_GE(device, 0);
dh::safe_cuda(cudaSetDevice(device));