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

[dask] Add seed to demos. #10009

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions demo/dask/cpu_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def main(client):
# generate some random data for demonstration
m = 100000
n = 100
X = da.random.random(size=(m, n), chunks=100)
y = da.random.random(size=(m,), chunks=100)
rng = da.random.default_rng(1)
X = rng.normal(size=(m, n))
y = X.sum(axis=1)

# DaskDMatrix acts like normal DMatrix, works as a proxy for local
# DMatrix scatter around workers.
Expand Down
7 changes: 5 additions & 2 deletions demo/dask/gpu_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Example of training with Dask on GPU
====================================
"""
import cupy as cp
import dask_cudf
from dask import array as da
from dask import dataframe as dd
Expand Down Expand Up @@ -72,10 +73,12 @@ def using_quantile_device_dmatrix(client: Client, X: da.Array, y: da.Array) -> d
with LocalCUDACluster(n_workers=2, threads_per_worker=4) as cluster:
with Client(cluster) as client:
# generate some random data for demonstration
rng = da.random.default_rng(1)

m = 100000
n = 100
X = da.random.random(size=(m, n), chunks=10000)
y = da.random.random(size=(m,), chunks=10000)
X = rng.normal(size=(m, n))
y = X.sum(axis=1)

print("Using DaskQuantileDMatrix")
from_ddqdm = using_quantile_device_dmatrix(client, X, y)
Expand Down
Loading