【发布时间】:2022-01-19 00:57:05
【问题描述】:
我正在尝试使用 Client.get 方法在远程集群中计算 dask 自定义图,但我遇到了以下错误:AssertionError: daemonic processes are not allowed to have children
我意识到 dask 图中的底层方法之一使用了进程池,这会导致引发此错误,因为 dask 自己也尝试使用进程池。所以,我解决这个问题的方法是使用 LocalCluster 并传递参数processes=False。但是,不幸的是,如果我使用连接到远程集群的客户端,dask 不会让我通过process=False,并且使用 --nprocs=1 参数初始化远程工作人员也无法正常工作.
总而言之,我可以运行图,但是我在计算 dask 图时不能使用多处理能力,并且不能使用远程集群,这很令人沮丧。关于如何实现其中一项(或两项)要求的任何想法?
提前致谢
代码示例
这是我打算做的,但得到了 AssertionError 被抛出:
from multiprocessing import Pool
from dask.distributed import Client
client = Client(<some-remote-ip-address-here>)
def foo():
pool = Pool() # the exception is raised here, on the Pool object initialization
... does something here ...
returns True
graph = {'result': foo}
client.get(graph, 'result')
这就是我“修复”它的方式,移除了多处理功能,并设置了一个本地集群:
from multiprocessing import Pool
from dask.distributed import Client
client = Client(processes=False) # this yields a LocalCluster that doesn't have multiprocessing capabilities (doc is very brief and not very helpful: http://distributed.dask.org/en/stable/api.html#distributed.LocalCluster)
def foo():
pool = Pool() # no exception is raised
... does something here ...
returns True
graph = {'result': foo}
client.get(graph, 'result')
【问题讨论】:
-
可以为本地池创建一个最小的工作示例吗?如果没有,您至少可以显示生成此错误的函数调用和完整的回溯吗?
-
刚刚提供了一个代码示例来更好地说明问题@PaulH
-
您为什么要尝试将 dask 与多处理混合使用?但是是的 - 简短的回答是不要/你不能这样做
-
好的,如何设置不使用多处理的远程集群?
-
不确定这是否是您所追求的,但对于编排(如果需要,使用 mpi),这可能很有用snakemake.readthedocs.io
标签: python multiprocessing cluster-computing dask distributed-computing