CommencerCommencer gratuitement

Clusters and clients

Depending on your computer hardware and the calculation you are trying to complete, it may be faster to run it using a mixture of threads and processes. To do this, you need to set up a local cluster.

There are two ways to set up a local cluster that Dask will use. The first way is to create the local cluster and pass it to a client. This is very similar to how you would set up a client to run across a cluster of computers! The second way is to use the client directly and allow it to create the local cluster itself. This is a shortcut that works for local clusters, but not for the other types of cluster.

In this exercise, you will create clients using both methods.

Be careful when creating the cluster and clients. If you configure them incorrectly, your session may time out.

Cet exercice fait partie du cours

Parallel Programming with Dask in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Import Client and LocalCluster
from ____ import ____, ____

# Create a thread-based local cluster
cluster = LocalCluster(
	processes=____,
    n_workers=____,
    threads_per_worker=____,
)

# Create a client
client = ____
Modifier et exécuter le code