创建Dask集群时默认n_workers?

问题描述 投票:0回答:1

简单的问题。如果我使用以下代码创建 Dask 集群:

from dask.distributed import Client

client = Client()

它将创造多少工人?我在一台机器上运行这段代码,它创建了 4 个工作线程。我在服务器上运行相同的代码,它创建了 8 个工作线程。它是否只是根据可用资源创造尽可能多的东西?在源代码中,文档字符串中没有列出

n_workers
的默认值。我正在尝试了解如何自动创建集群,而不必提前知道我可用的资源。

class LocalCluster(SpecCluster):
"""Create local Scheduler and Workers

This creates a "cluster" of a scheduler and workers running on the local
machine.

Parameters
----------
n_workers: int
    Number of workers to start
memory_limit: str, float, int, or None, default "auto"
    Sets the memory limit *per worker*.

    Notes regarding argument data type:

    * If None or 0, no limit is applied.
    * If "auto", the total system memory is split evenly between the workers.
    * If a float, that fraction of the system memory is used *per worker*.
    * If a string giving a number of bytes (like ``"1GiB"``), that amount is used *per worker*.
    * If an int, that number of bytes is used *per worker*.
python dask cpu-usage dask-distributed
1个回答
0
投票

dask.distributed
使用
os.cpu_count()
获取机器上可用的 CPU 数量,然后将其与每个工作线程的线程数一起使用来计算工作线程的数量。

© www.soinside.com 2019 - 2024. All rights reserved.