簡體   English   中英

如何在 GKE for DASK 中增加調度程序內存

[英]How to increase scheduler memory in GKE for DASK

我在 GCP 上部署了一個 kubernetes 集群,結合了 prefect 和 dask。 作業在正常情況下運行良好,但無法擴展 2 倍的數據。 到目前為止,我已將范圍縮小到調度程序因高內存使用而被關閉。 Dask 調度程序內存一旦內存使用量達到 2GB,作業就會因“未檢測到心跳”錯誤而失敗。

有一個單獨的構建 python 文件可用,我們可以在其中設置工作內存和 CPU。 有一個 dask-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

首先解釋為什么 Flow 心跳存在:Prefect 使用心跳來檢查您的 Flow 是否仍在運行。 如果 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 ,你可以同時設置:

  • scheduler_memory - 默認為 4 GiB
  • worker_memory - 默認為 8 GiB

以下是您在流程中設置的方法:

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 = executor

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM