google-cloud-platform - 在 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
解决方案
推荐阅读
- django - 如何从 ModelForm 中保存数据?
- c# - 我不明白代码的 Try Catch Exception 部分
- android - 使用新的 prefixText 时如何更改 TextInputLayout 的提示填充?
- java - Akka Http 请求和响应模式
- typescript - 如何使用 TypeORM 在 React-Native 中处理 SQLite 迁移?
- android - AppBarLayout 中的 NavHostFragment 内带有 TabLayout 的 ViewPager
- mysql - MYSQL 变量限制和子查询
- fullcalendar - (Fullcalendar 4 VueJs)在日历标题中添加自定义元素
- python - Matplotlib 在每次执行时随机忽略传递的参数
- python - Pandas:如何创建一个列,该列指示值何时出现在另一列中预先设定的行数?