So I've a Flask web app that will be exposing some deep learning models.
I built the image and everything works fine.
the problem is the size of this image is 5.58GB! which is a bit ridiculous.
I have some deep learning models that are copied during the build, I thought they might be the culprit but their size combined does not exceed 300MB so that's definately not it.
upon checking the history and the size of each layer I discovered this:
RUN /bin/sh -c pip install -r requirements.txtis taking up 771MB.RUN /bin/sh -c pip install torch==1.10.2is taking up 2.8GB!RUN /bin/sh -c apt-get install ffmpeg libsm6 libxext6is taking up 400MB.
so how do I incorporate these libraries while keeping image size reasonable? is it ok to have images of these size when deploying ml models in python?
below is the root directory:
Dockerfile:
FROM python:3.7.13
WORKDIR /app
COPY ["rdm.pt", "autosort_model.pt", "rotated_model.pt", "yolov5x6.pt", "/app/"]
RUN pip install torch==1.10.2
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6 -y
COPY . /app
CMD python ./app.py
.dockerignore:
Dockerfile
README.md
__pycache__
