-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce Docker image size from 4.8GB to 2.2GB #615
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pquentin It looks like the torch+cpu
variant is only available for Intel/AMD CPUs:
torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl
torch-1.13.1+cpu-cp310-cp310-win_amd64.whl
This means the image won't build on systems running Docker Engine on Apple Silicon or other system with an ARM CPU. Are we comfortable with that restriction? 🤔
Later edit: When building for x86_64/amd64
, it makes sense to use the torch+cpu
variant as it doesn't install the large NVIDIA deps we don't need. For aarch64
though, with the normal torch
package, the image size is only 1.3GB
so we don't need to rely on the torch+cpu
variant.
Avoids downloading large & unnecessary NVIDIA deps defined in the package on PyPI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is great.
The part that is left is building those images in Buildkite, modifying https://github.com/elastic/eland/blob/main/.buildkite/release-docker/run.sh. I've started reading https://docs.docker.com/build/building/multi-platform/ but it seems quite complicated. Do you have any suggestions about the best approach here?
Co-authored-by: David Olaru <dolaru@elastic.co>
Thanks to @dolaru, I was able to adapt run.sh to build and push an ARM image. This command worked:
I would appreciate if an Elastic employee with an Apple Silicon Macbook could test the resulting image. (Ping me offline to get instructions.) |
Good stuff @pquentin! I can confirm that the ARM container image works as intended. 👍🏽 I successfully imported the |
Closes #600
This was done by using the torchcpu PyPI package and not storing the PyPI cache in the Docker image.
Tested using
docker run -it --rm --network host -e ES_USERNAME=$ES_USERNAME -e ES_PASSWORD=$ES_PASSWORD eland eland_import_hub_model --cloud-id $CLOUD_ID --hub-model-id elastic/distilbert-base-cased-finetuned-conll03-english --task-type ner