首页 > 解决方案 > 在 Cloud Run 上加载深度学习模型比在 Cloud 函数上加载它们要慢

问题描述

我正在测试两个 Google Cloud 产品,即:Cloud Functions 和 Cloud Run。我倾向于使用云运行,因为它允许您进行更多的自定义和可观察性。

但是我注意到,出于某种原因,Cloud Functions 比 Cloud Run 更快,尽管使用相同的代码和配置(2 GB RAM)。即使增加 Cloud Run 的 RAM 或核心数量也不能提高速度。

我的主要问题是模型加载时间(以获得快速冷启动),在 Cloud Function 中它需要 Cloud Run 中的 1/5,这对我的用例非常不利。

我进行了基准测试,这是许多不同模型重复出现的模式,有人知道为什么会这样吗?

更新:我的码头文件:

FROM python:3.8
# set a directory for the app
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
# install dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install Flask gunicorn
RUN apt-get install util-linux
# run the command
CMD exec gunicorn --bind :$PORT --timeout 0 main:app

标签: google-cloud-platformgoogle-cloud-functionsgoogle-cloud-run

解决方案


推荐阅读