Skip to content
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

Merged
merged 5 commits into from
Oct 5, 2023

Conversation

pquentin
Copy link
Member

@pquentin pquentin commented Oct 3, 2023

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

Copy link
Member

@dolaru dolaru left a 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.

Copy link
Member Author

@pquentin pquentin left a 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?

Dockerfile Show resolved Hide resolved
Dockerfile Show resolved Hide resolved
Co-authored-by: David Olaru <dolaru@elastic.co>
@pquentin
Copy link
Member Author

pquentin commented Oct 5, 2023

Thanks to @dolaru, I was able to adapt run.sh to build and push an ARM image. This command worked:

ENVIRONMENT=staging RELEASE_VERSION=8.9.0 with-vault-ci bash .buildkite/release-docker/run.sh

I would appreciate if an Elastic employee with an Apple Silicon Macbook could test the resulting image. (Ping me offline to get instructions.)

@dolaru
Copy link
Member

dolaru commented Oct 5, 2023

Good stuff @pquentin! I can confirm that the ARM container image works as intended. 👍🏽

I successfully imported the elastic/distilbert-base-cased-finetuned-conll03-english model using eland_import_hub_model in that container image.

@pquentin pquentin merged commit 9273636 into elastic:main Oct 5, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop installing GPU dependencies
2 participants