Python में Dask के साथ Parallel Programming
James Fulton
Climate Informatics Researcher
dask.delayed() से बनी delayed पाइपलाइन्स# डिफॉल्ट उपयोग करें result = x.compute()result = dask.compute(x)# थ्रेड्स उपयोग करें result = x.compute(scheduler='threads')result = dask.compute(x, scheduler='threads')# प्रोसेस उपयोग करें 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>
क्लस्टर बनाएँ और उसे क्लायंट में पास करें
cluster = LocalCluster(
processes=True,
n_workers=4,
threads_per_worker=2
)
client = Client(cluster)
print(client)
<Client: ... processes=4 threads=8, ...>
ऐसा क्लायंट बनाएँ जो अपना क्लस्टर खुद बनाएगा
client = Client(
processes=True,
n_workers=4,
threads_per_worker=2
)
print(client)
<Client: ... processes=4 threads=8, ...>
client = Client(processes=True) # डिफॉल्ट क्लायंट ही उपयोग होता है result = x.compute()# फिर भी अन्य शेड्यूलर चुन सकते हैं result = x.compute(scheduler='threads')# क्लायंट को स्पष्ट रूप से उपयोग कर सकते हैं result = client.compute(x)
LocalCluster() - आपके कंप्यूटर पर क्लस्टर.Python में Dask के साथ Parallel Programming