Closed StroescuTheo closed 1 month ago
Great idea! I get about the same ratio of size reduction with the staged build.
One update I'll make to the Dockerfile - move the env variable declearation
ENV PYTHONPATH=.
to the Runtime stage where its needed for internal reference by meme_search modules.
While torch
is required for both cpu / gpu instances, there is opportunity to bifurcate the installs. e.g., when not using a GPU the torch
install is smaller.
In my testing the env variable declaration
ENV PYTHONPATH=.
needs to occur in the runtime stage (at present its in build). Can you confirm and move?
Nevermind - I'll just merge and re-locate this one line.
The current Docker image size is approximately 9GB, which is quite large. To address this, I propose splitting the image into two stages:
This approach has significantly reduced the Docker image size by approximately 4GB during my tests.
Also, are there any python packages that don't need to be installed if I'm running without a gpu? If there are, I would also recommend removing them from the original requirements and adding them in the Dockerfile, conditioned by an Environment variable. Something like:
Or even better, have 2 reqiurements.txt files (requirements-cpu.txt and requirements-gpu.txt) and copy the required one, based on a env variable.