如何终止由DASK多处理调度程序开始的工人



在长时间使用DASK多处理调度程序后,我注意到Python过程是由多处理调度程序启动的。我如何重新启动工作池?

update:您可以做到这一点杀死工人由多处理调度程序开始:

从dask.context导入_globalspool = _globals.pop('poop')#从全球范围内删除池以使dask创建一个新的pool.close()pool..terminate()pool.join()

第一个答案:

对于消耗大量内存的任务,我也更喜欢在Localhost中使用distributed调度程序。

这很简单:

  1. 在一个外壳中启动调度程序:
$ dask-Scheduler分布式。Scheduler-信息-----------------------------------------------------------------------------------------------------------------------------------------------------------------------distriptited.scheduler-信息 - 调度程序,网址:1.2.3.4:8786distriptited.scheduler-信息 -  http,网址:1.2.3.4:9786distribleted.bokeh.application-信息 - 网络UI:http://1.2.3.4:8787/status/分布式。Scheduler-信息-----------------------------------------------------------------------------------------------------------------------------------------------------------------------distription.core-信息 - 连接从1.2.3.4:56240到调度程序distription.core-信息 - 连接从1.2.3.4:56241到调度程序distription.core-信息 - 连接从1.2.3.4:56242到调度程序
  1. 在另一个外壳中启动工人,您可以相应地调整参数:
$ dask-worker -nprocs 8  -  nthreads 1--膜限制.8 1.2.3.4:8786Distriptuct.Nanny-信息 - 启动Nanny:127.0.0.1:61760Distription.Nanny-信息 - 启动保姆:127.0.0.1:61761Distribal.Nanny-信息 - 开始保姆:127.0.0.1:61762Distriptuct.Nanny-信息 - 开始保姆:127.0.0.1:61763distription.worker-信息 - 启动工人在:127.0.0.1:61765distription.worker-信息 - 保姆在:127.0.0.1:61760distriptuct.worker-信息 -  http at:127.0.0.1:61764distription.worker-信息 - 等待连接到:127.0.0.1:8786distriptited.worker-信息-------------------------------------------------------------------------------------------------------------------------------------------------------Distribute.Worker-信息 - 线程:1Distription.Nanny-信息 - 启动保姆:127.0.0.1:61767Distribation.Worker-信息 - 内存:1.72 GBdistription.worker -info-本地目录:/var/folder/55/nbg15c6j4k3cg06tjfhqypd40000 gn/t/t/nanny -11ygswb9...
  1. 最终使用distributed.Client类提交您的工作。
在[1]中:来自分布式导入客户端在[2]中:客户端=客户端('1.2.3.4:8786')在[3]中:客户<客户端:调度程序=" 127.0.0.1:61829" processes = 8 cores = 8>在[4]中:摘自分布式。在[5]中:import dask.bag在[6]中:data = dask.bag.range(10000,8)在[7]中:数据dask.bag在[8]中:future = client.compute(data.sum())在[9]中:进度(未来)[########################################100%完成|0.0s在[10]:future.result()49995000

我发现这种方式比默认调度程序更可靠。我更喜欢明确提交任务并处理未来以使用进度小部件,这在笔记本中真的很不错。另外,您仍然可以在等待结果时做一些事情。

如果您由于内存问题而遇到错误,则可以重新启动工人或调度程序(重新开始),使用较小的数据并重试。

最新更新