使用 Kubernetes 服务 OOMKilled 或 Evicted pod 的 Tensorflow

Tensorflow serving OOMKilled or Evicted pod with Kubernetes

我正在使用 Kubernetes (GKE) 部署 tensorflow 服务映像 (tensorflow/serving:latest-gpu),GPU 节点 (K80) 托管在 GCP 上。

命令:

command: ["tensorflow_model_server"] args: ["--port=8500", "--rest_api_port=8501", "--enable_batching", "--batching_parameters_file=/etc/config/batching_parameters","--model_config_file=/etc/config/model_config"]

批处理参数 :

maxBatchSize: 4096 batchTimeoutMicros: 25000 maxEnqueuedBatches: 16 numBatchThreads: 16

我使用 --model_config_file 从 GCS 存储桶加载版本模型。 Tensorflow 服务拉取每个新版本模型并加载它,完成后他卸载旧模型(但看起来他将其保存在内存中)

当我在主机上的最大可用资源下使用 limit/request 时,pod 完成 OOMKilled 因为允许使用最大内存。 但是当我使用 limit/request 匹配主机(专用)上的最大可用资源时,看起来内存已刷新以遵守此最大值。

你知道我们是否可以将最大内存设置为 tensorflow 或告诉他使用 cgroup 内存限制(由 docker/kubernetes 使用)吗?
我们可以完全刷新旧版本模型以释放内存吗?
此外,每次我执行请求时,它都会增加内存并且永远不会释放它。你有什么想法吗?

节点信息:
7 个 vCPU
30 Gb 内存
1 个 GPU K80

模型大小:~8Gb

limit/request 内存: 20Gb 或 30Gb -> 多个版本模型加载后 OOMKilled

Last State:     Terminated
      Reason:       OOMKilled
      Exit Code:    137

no limit/request -> Tensorflow 因高内存消耗而被 Kubernetes 驱逐。

Status:             Failed
Reason:             Evicted
Message:            The node was low on resource: memory. Container tensorserving was using 24861136Ki, which exceeds its request of 0.

谢谢,

此致
文斯

作为解决方法,我选择使用不同的内存分配器(默认为 malloc):tcmalloc(google 内存分配实现)解决了我的问题而没有性能问题。

(这是一个丑陋的部署文件,但它是为了简化可视化)。
Kubernetes 部署 tensorflow 服务:

spec:
  containers:
    - name: tensorserving
      image: tensorflow/serving:1.14.0-gpu"
      command: [""]
      args:
        - "sh"
        - "-c"
        - "apt-get update && apt-get install google-perftools -y && LD_PRELOAD=/usr/lib/libtcmalloc.so.4 tensorflow_model_server --port=8500 --rest_api_port=8501 --monitoring_config_file=/etc/config/monitoring_config --enable_batching --batching_parameters_file=/etc/config/batching_parameters --model_config_file=/etc/config/model_config"