Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Update call to dask client persist #3474

Merged
merged 5 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion python/cuml/common/import_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -87,6 +87,14 @@ def has_pytest_benchmark():
return False


def check_min_dask_version(version):
try:
import dask
return LooseVersion(dask.__version__) >= LooseVersion(version)
except ImportError:
return False


def check_min_numba_version(version):
return LooseVersion(str(numba.__version__)) >= LooseVersion(version)

Expand Down
12 changes: 10 additions & 2 deletions python/cuml/dask/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
# limitations under the License.
#

import dask
import logging
import os
import numba.cuda
Expand All @@ -22,6 +23,7 @@
from dask.distributed import default_client, wait

from cuml.common import device_of_gpu_matrix
from cuml.common.import_utils import check_min_dask_version

from asyncio import InvalidStateError

Expand Down Expand Up @@ -133,7 +135,13 @@ def persist_across_workers(client, objects, workers=None):
"""
if workers is None:
workers = client.has_what().keys() # Default to all workers
return client.persist(objects, workers={o: workers for o in objects})

if check_min_dask_version("2020.12.0"):
JohnZed marked this conversation as resolved.
Show resolved Hide resolved
with dask.annotate(workers=set(workers)):
return client.persist(objects)

else:
return client.persist(objects, workers={o: workers for o in objects})


def raise_exception_from_futures(futures):
Expand Down