DigitalOcean 应用平台在 docker 构建期间显示内存不足

问题描述 投票:0回答:1

我已经使用 Dockerfile 设置了一个 Flask Web 服务进行部署。我添加了一些 ML 相关的包,例如

torch
torchvision
等以及很多其他包。

docker 镜像在我的本地 Mac 中构建良好,但在执行以下操作后在数字海洋中失败。

它保持在

[my-project] [2024-06-05 13:05:13] │ INFO[0162] Taking snapshot of files...
阶段 1 小时以上,但随后显示内存不足。这件事是最近发生的,我已经为这个项目有了一个有效的部署。但新的部署在构建阶段失败了。

构建冻结于

[my-project] [2024-06-05 13:05:10] │   Running setup.py install for flasgger: finished with status 'done'
    [my-project] [2024-06-05 13:05:11] │ Successfully installed Flask-3.0.3 GitPython-3.1.43 Jinja2-3.1.4 MarkupSafe-2.1.5 PyYAML-6.0.1 Werkzeug-3.0.3 annotated-types-0.7.0 attrs-23.2.0 beautifulsoup4-4.12.3 blinker-1.8.2 cachetools-5.3.3 certifi-2024.6.2 charset-normalizer-3.3.2 click-8.1.7 contourpy-1.2.1 cycler-0.12.1 decorator-4.4.2 filelock-3.14.0 flasgger-0.9.7.1 fonttools-4.53.0 fsspec-2024.6.0 gitdb-4.0.11 google-3.0.0 google-ai-generativelanguage-0.6.4 google-api-core-2.19.0 google-api-python-client-2.131.0 google-auth-2.29.0 google-auth-httplib2-0.2.0 google-generativeai-0.5.4 googleapis-common-protos-1.63.0 grpcio-1.64.0 grpcio-status-1.62.2 gunicorn-22.0.0 httplib2-0.22.0 idna-3.7 imageio-2.34.1 imageio-ffmpeg-0.5.1 itsdangerous-2.2.0 jsonschema-4.22.0 jsonschema-specifications-2023.12.1 kiwisolver-1.4.5 loguru-0.7.2 matplotlib-3.9.0 mistune-3.0.2 moviepy-1.0.3 mpmath-1.3.0 networkx-3.3 numpy-1.26.4 nvidia-cublas-cu12-12.1.3.1 nvidia-cuda-cupti-cu12-12.1.105 nvidia-cuda-nvrtc-cu12-12.1.105 nvidia-cuda-runtime-cu12-12.1.105 nvidia-cudnn-cu12-8.9.2.26 nvidia-cufft-cu12-11.0.2.54 nvidia-curand-cu12-10.3.2.106 nvidia-cusolver-cu12-11.4.5.107 nvidia-cusparse-cu12-12.1.0.106 nvidia-nccl-cu12-2.20.5 nvidia-nvjitlink-cu12-12.5.40 nvidia-nvtx-cu12-12.1.105 opencv-contrib-python-4.10.0.82 opencv-python-4.10.0.82 opencv-python-headless-4.10.0.82 packaging-24.0 pandas-2.2.2 pillow-10.3.0 proglog-0.1.10 proto-plus-1.23.0 protobuf-4.25.3 psutil-5.9.8 py-cpuinfo-9.0.0 pyasn1-0.6.0 pyasn1_modules-0.4.0 pydantic-2.7.2 pydantic_core-2.18.3 pyparsing-3.1.2 python-dateutil-2.9.0.post0 python-dotenv-1.0.1 pytz-2024.1 referencing-0.35.1 requests-2.32.3 rpds-py-0.18.1 rsa-4.9 scipy-1.13.1 seaborn-0.13.2 setuptools-70.0.0 six-1.16.0 smmap-5.0.1 soupsieve-2.5 sympy-1.12.1 torch-2.3.0 torchvision-0.18.0 tqdm-4.66.4 triton-2.3.0 typing_extensions-4.12.1 tzdata-2024.1 ultralytics-8.2.28 ultralytics-thop-0.2.7 uritemplate-4.1.1 urllib3-2.2.1 wheel-0.43.0
    [my-project] [2024-06-05 13:05:11] │ 
    [my-project] [2024-06-05 13:05:11] │ [notice] A new release of pip is available: 23.0.1 -> 24.0
    [my-project] [2024-06-05 13:05:11] │ [notice] To update, run: pip install --upgrade pip
    [my-project] [2024-06-05 13:05:13] │ INFO[0162] Taking snapshot of files... 

后果

[2024-06-05 13:05:10] │   Running setup.py install for flasgger: started
[2024-06-05 13:05:10] │   Running setup.py install for flasgger: finished with status 'done'
[2024-06-05 13:05:11] │ Successfully installed Flask-3.0.3 GitPython-3.1.43 Jinja2-3.1.4 MarkupSafe-2.1.5 PyYAML-6.0.1 Werkzeug-3.0.3 annotated-types-0.7.0 attrs-23.2.0 beautifulsoup4-4.12.3 blinker-1.8.2 cachetools-5.3.3 certifi-2024.6.2 charset-normalizer-3.3.2 click-8.1.7 contourpy-1.2.1 cycler-0.12.1 decorator-4.4.2 filelock-3.14.0 flasgger-0.9.7.1 fonttools-4.53.0 fsspec-2024.6.0 gitdb-4.0.11 google-3.0.0 google-ai-generativelanguage-0.6.4 google-api-core-2.19.0 google-api-python-client-2.131.0 google-auth-2.29.0 google-auth-httplib2-0.2.0 google-generativeai-0.5.4 googleapis-common-protos-1.63.0 grpcio-1.64.0 grpcio-status-1.62.2 gunicorn-22.0.0 httplib2-0.22.0 idna-3.7 imageio-2.34.1 imageio-ffmpeg-0.5.1 itsdangerous-2.2.0 jsonschema-4.22.0 jsonschema-specifications-2023.12.1 kiwisolver-1.4.5 loguru-0.7.2 matplotlib-3.9.0 mistune-3.0.2 moviepy-1.0.3 mpmath-1.3.0 networkx-3.3 numpy-1.26.4 nvidia-cublas-cu12-12.1.3.1 nvidia-cuda-cupti-cu12-12.1.105 nvidia-cuda-nvrtc-cu12-12.1.105 nvidia-cuda-runtime-cu12-12.1.105 nvidia-cudnn-cu12-8.9.2.26 nvidia-cufft-cu12-11.0.2.54 nvidia-curand-cu12-10.3.2.106 nvidia-cusolver-cu12-11.4.5.107 nvidia-cusparse-cu12-12.1.0.106 nvidia-nccl-cu12-2.20.5 nvidia-nvjitlink-cu12-12.5.40 nvidia-nvtx-cu12-12.1.105 opencv-contrib-python-4.10.0.82 opencv-python-4.10.0.82 opencv-python-headless-4.10.0.82 packaging-24.0 pandas-2.2.2 pillow-10.3.0 proglog-0.1.10 proto-plus-1.23.0 protobuf-4.25.3 psutil-5.9.8 py-cpuinfo-9.0.0 pyasn1-0.6.0 pyasn1_modules-0.4.0 pydantic-2.7.2 pydantic_core-2.18.3 pyparsing-3.1.2 python-dateutil-2.9.0.post0 python-dotenv-1.0.1 pytz-2024.1 referencing-0.35.1 requests-2.32.3 rpds-py-0.18.1 rsa-4.9 scipy-1.13.1 seaborn-0.13.2 setuptools-70.0.0 six-1.16.0 smmap-5.0.1 soupsieve-2.5 sympy-1.12.1 torch-2.3.0 torchvision-0.18.0 tqdm-4.66.4 triton-2.3.0 typing_extensions-4.12.1 tzdata-2024.1 ultralytics-8.2.28 ultralytics-thop-0.2.7 uritemplate-4.1.1 urllib3-2.2.1 wheel-0.43.0
[2024-06-05 13:05:11] │ 
[2024-06-05 13:05:11] │ [notice] A new release of pip is available: 23.0.1 -> 24.0
[2024-06-05 13:05:11] │ [notice] To update, run: pip install --upgrade pip
[2024-06-05 13:05:13] │ INFO[0162] Taking snapshot of files...                  
[2024-06-05 13:07:40] │ 
[2024-06-05 13:07:40] │ command exited with code -1
[2024-06-05 13:07:40] │ 
[2024-06-05 13:07:40] │  ✘ build failed

我的 Dockerfile

# Use the official Python image from the Docker Hub
FROM python:3.10-slim

# Set work directory
WORKDIR /app

# Install gcc and other dependencies
RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*

# Create a virtual environment and activate it
RUN python -m venv /opt/venv

# Ensure the virtual environment is used for subsequent commands
ENV PATH="/opt/venv/bin:$PATH"

# Install Python dependencies inside the virtual environment
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt

# Copy project files
COPY . /app/

# Expose the port on which the Flask app will run
EXPOSE 5000

# Set the environment variable for Flask
ENV FLASK_APP=app.app

# Run the Flask app with Gunicorn and set timeout to 7200 seconds
CMD ["gunicorn", "--timeout", "7200", "-b", "0.0.0.0:5000", "app.app:app"]
python flask digital-ocean
1个回答
0
投票

我在 Digital Ocean 构建 Python 容器方面遇到了很多麻烦。

基本上,您要么必须减少所需的内存,这是困难/不可能的,要么自己构建并按照此处的说明进行推送:https://docs.digitalocean.com/support/why-is-my-app-platform-build -或部署失败并出现内存不足错误/

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.