我已经使用prefect和dask的组合在GCP上部署了一个kubernetes集群。这些作业在正常情况下运行良好,但它无法扩展到数据的2倍。到目前为止,我已经将范围缩小到调度器由于高内存使用率而关闭。Dask scheduler Memory一旦内存使用量达到2 2GB,作业就会失败,并显示“未检测到心跳”错误。
有一个单独的构建python文件,我们可以在其中设置工作内存和cpu。有一个dask-gateway包,我们可以在其中获取Gateway选项并设置工作内存。
options.worker_memory = 32
options.worker_cores = 10
cluster = gateway.new_cluster(options)
cluster.adapt(minimum=4, maximum=20)我无法确定在哪里以及如何增加dask-scheduler的内存分配。
Specs:
Cluster Version: 1.19.14-gke.1900
Machine type - n1-highmem-64
Autoscaling set to 6 - 1000 nodes per zone
all nodes are allocated 63.77 CPU and 423.26 GB发布于 2021-11-15 13:59:36
为了解释为什么流心跳首先存在: Prefect使用心跳来检查您的流是否仍在运行。如果Prefect没有心跳,在远程执行环境(如Kubernetes作业)上失去通信并终止的流将在UI中永久显示为正在运行。通常,“未检测到心跳”是由于内存不足或流执行长时间运行的作业造成的。
您可以尝试的一种解决方案是在您的运行配置上设置以下环境变量-这将把心跳行为从进程更改为线程,并有助于解决该问题:
from prefect.run_configs import UniversalRun
flow.run_config = UniversalRun(env={"PREFECT__CLOUD__HEARTBEAT_MODE": "thread"})正如您所提到的,最好的解决方案是增加Dask工作人员的内存。如果您使用的是长时间运行的集群,可以这样设置:
dask-worker tcp://scheduler:port --memory-limit="4 GiB"如果您将集群类传递给Dask执行器,例如coiled.Cluster,您可以同时设置这两个类:
下面是你如何在你的流程中进行设置:
import coiled
from prefect import Flow
from prefect.executors import DaskExecutor
flow = Flow("test-flow")
executor = DaskExecutor(
cluster_class=coiled.Cluster,
cluster_kwargs={
"software": "user/software_env_name",
"shutdown_on_close": True,
"name": "prefect-cluster",
"scheduler_memory": "4 GiB",
"worker_memory": "8 GiB",
},
)
flow.executor = executorhttps://stackoverflow.com/questions/69972916
复制相似问题