Python ile Dask ile Paralel Programlama
James Fulton
Climate Informatics Researcher
dask.delayed() ile oluşturulan gecikmeli ardışık düzenler# Varsayılanı kullan result = x.compute()result = dask.compute(x)# İş parçacıklarını kullan result = x.compute(scheduler='threads')result = dask.compute(x, scheduler='threads')# Süreçleri kullan result = x.compute(scheduler='processes')result = dask.compute(x, scheduler='processes')
from dask.distributed import LocalCluster
cluster = LocalCluster(
processes=True,
n_workers=2,
threads_per_worker=2
)
print(cluster)
LocalCluster(..., workers=2, threads=4, memory=31.38 GiB)
from dask.distributed import LocalCluster
cluster = LocalCluster(
processes=False,
n_workers=2,
threads_per_worker=2
)
print(cluster)
LocalCluster(..., workers=2, threads=4, memory=31.38 GiB)
cluster = LocalCluster(processes=True)
print(cluster)
LocalCluster(..., workers=4 threads=8, memory=31.38 GiB)
cluster = LocalCluster(processes=False)
print(cluster)
LocalCluster(..., workers=1 threads=8, memory=31.38 GiB)
from dask.distributed import Client, LocalCluster
cluster = LocalCluster(
processes=True,
n_workers=4,
threads_per_worker=2
)
client = Client(cluster)
print(client)
<Client: 'tcp://127.0.0.1:61391' processes=4 threads=8, memory=31.38 GiB>
Kümeyi oluşturup istemciye aktarın
cluster = LocalCluster(
processes=True,
n_workers=4,
threads_per_worker=2
)
client = Client(cluster)
print(client)
<Client: ... processes=4 threads=8, ...>
Kendi kümesini oluşturacak bir istemci oluşturun
client = Client(
processes=True,
n_workers=4,
threads_per_worker=2
)
print(client)
<Client: ... processes=4 threads=8, ...>
client = Client(processes=True) # Varsayılan olarak istemciyi kullanır result = x.compute()# Diğer zamanlayıcılara geçilebilir result = x.compute(scheduler='threads')# İstemci açıkça kullanılabilir result = client.compute(x)
LocalCluster() - Bilgisayarınızda bir küme.Python ile Dask ile Paralel Programlama