【问题标题】:How do I run a serverless batch job in Google Cloud如何在 Google Cloud 中运行无服务器批处理作业
【发布时间】:2020-01-29 10:14:22
【问题描述】:

我有一个批处理作业需要几个小时才能运行。如何在 Google Cloud 上以无服务器方式运行它?

AppEngine、Cloud Functions 和 Cloud Run 的时间限制为 10-15 分钟。我不想在 Apache Beam 中重写我的代码。

Google Cloud 上是否有与 AWS Batch 等效的产品?

【问题讨论】:

  • 你的模型框架是什么?数据类型有哪些?数据来自哪里?你的工作类型是什么?
  • @samuel liew 为什么社区的回答被删除了?

标签: google-cloud-platform google-cloud-functions batch-processing serverless google-cloud-run


【解决方案1】:

AI Platform Training 是无服务器且长期存在的。将批处理代码包装在 Docker 容器中,推送到 gcr.io,然后执行:

gcloud ai-platform jobs submit training gpu_function \
       --scale-tier BASIC \ 
       --region $REGION \ 
       --master-image-uri gcr.io/$PROJECT_ID/some-image-name

您可以运行任意 Docker 容器——它不必是机器学习作业。详情见:

https://cloud.google.com/ml-engine/docs/custom-containers-training

【讨论】:

    【解决方案2】:

    Google Cloud 不提供与 AWS Batch 相媲美的产品(请参阅 https://cloud.google.com/docs/compare/aws/#service_comparisons)。

    相反,您需要使用 Cloud Tasks 或 Pub/Sub 将工作委派给另一个产品,例如 Compute Engine,但这缺乏以“无服务器”方式执行此操作的能力。

    【讨论】:

      【解决方案3】:

      answerHow to make GCE instance stop when its deployed container finishes? 也适用于您:

      简而言之:

      • 首先对批处理进行 dockerize。
      • 然后,创建一个实例:
        • 使用容器优化图像
        • 并使用启动脚本来拉取您的 docker 映像、运行它并在最后关闭机器。

      【讨论】:

        【解决方案4】:

        我也遇到过同样的问题。就我而言,我选择了:

        1. Cloud Scheduler 通过推送到 Pub/Sub 来启动作业。
        2. Pub/Sub 触发 Cloud Functions。
        3. Cloud Functions 挂载一个 Compute Engine 实例。
        4. Compute Engine 运行批处理工作负载并自动终止实例 一旦完成。您可以在媒体上通过帖子阅读: https://link.medium.com/1K3NsElGYZ

        它可能会帮助您入门。还有一篇后续文章展示了如何在 Compute Engine 实例中使用 Docker 容器:https://medium.com/google-cloud/serverless-batch-workload-on-gcp-adding-docker-and-container-registry-to-the-mix-558f925e1de1

        【讨论】:

          【解决方案5】:

          您可以使用 Cloud Run。在撰写本文时,Cloud Run(完全托管)的超时时间增加到 60 分钟,但处于测试阶段。

          https://cloud.google.com/run/docs/configuring/request-timeout

          重要提示:尽管 Cloud Run(完全托管)的最大超时时间为 60 分钟,但通常只有 15 分钟或更短的超时时间可用:将超时时间设置为大于 15 分钟是一项 Beta 功能。

          【讨论】:

            【解决方案6】:

            批处理计算的另一种替代方法是使用Google Cloud Lifesciences

            使用 Cloud Life Sciences 的示例应用程序是 dsub

            或查看Cloud Life Sciences Quickstart documentation

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 2021-04-12
              • 1970-01-01
              • 2023-01-25
              • 2014-06-20
              • 2014-09-28
              • 1970-01-01
              • 2020-10-29
              相关资源
              最近更新 更多