Dask DataFrame 中的客户端 python | client.shutdown()

Clients in Dask DataFrame with python | client.shutdown()

我一直在使用 dask,当您处理具有高计算要求的大型脚本时,我有一个与 clients 相关的问题

client = Client(n_workers = NUM_PARALLEL)
...
more code
...
client.shutdown()

我看到有人在中途关闭客户端然后再初始化,这样对速度有好处吗?

另一方面,工作人员 运行 内存不足,您知道 compute() 几次 dask dataframe 是否是一个好习惯最后只计算一次,这可能超出了 pc 的性能。

I have seen some people that are shutting down the client in the middle of the process and then and then initializing it again, is it good for speed?

IIUC,对速度没有影响,在启动 scheduler/cluster 的时间方面可能会稍微变慢。唯一的一点好处是如果您正在共享资源,那么关闭集群将释放资源。

On the other hand, the workers are running out of memory, do you know if its a good practise to compute() several times the dask dataframe instead of computing it only once at the end, that may be beyond the performance capacity of the pc.

这真的取决于 DAG,如果减少 partitions/tasks 的数量,在中间步骤计算可能会有优势,特别是如果某些结果被多次计算。