Dask分布式工作人员无响应

时间:2019-09-09 11:44:29

标签: python-3.x dask dask-distributed

我正在使用Dask并行化转换过程。这是通过在每个任务中将转换过程作为子过程运行来实现的。我运行的转换过程最多消耗2GB的内存,大约需要30秒才能完成。 Dask使用了YarnCluster。

当我使用少量文件运行进程时,它可以正常工作。但是当我将任务扩展到超过1000个时,工作人员开始失败并显示以下消息:

distributed.core - INFO - Event loop was unresponsive in Worker for 29.41s.  This is often caused by long-running GIL-holding functions or moving large chunks of data. This can cause timeouts and instability.

从错误消息中,我可以排除大量数据的移动,因为我没有在任何工作程序或调度程序之间发送或接收大量数据。这让我有了GIL持有功能。我不了解在我的流程中是什么导致了GIL。

以下是我正在使用的配置:

YarnCluster(environment=f'python://{sys.executable}',
            name='Converter', n_workers=200, worker_vcores=1, worker_memory='4GiB')
client = Client(cluster)

在工作程序上运行的功能如下:

def convert_file(input_file, output_file):
    p = subprocess.Popen(f'python3 converter.py {input_file} {output_file}', shell=True, stdout=PIPE, stderr=PIPE)
    stdout, stderr = p.communicate()
    if p.returncode !=0:
        return 0
    return 1

使用client.submit(convert_file, input_file, output_file)here所述的迭代方式提交任务。

converter.py读取数据,对其进行处理并将其写入输出文件。加工过程涉及大熊猫。

更新

我浏览了日志的日志,发现这些工作线程超出了内存限制。我还记录了converter.py进程消耗的内存量。但是在转换过程中,内存无处接近极限。每次完成任务时,dask工作者实际上是否将某些信息存储在内存中?在调度程序中完成期货交易后,我还尝试取消期货交易,但没有帮助。

0 个答案:

没有答案
相关问题