-
Notifications
You must be signed in to change notification settings - Fork 757
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
Faster image rebuilding when only model artifacts are updated #1199
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1199 +/- ##
=======================================
Coverage 66.05% 66.05%
=======================================
Files 135 135
Lines 8544 8544
=======================================
Hits 5644 5644
Misses 2900 2900
Continue to review full report at Codecov.
|
# copy over model files | ||
COPY . /bento | ||
# copy over bundled_pip_dependencies | ||
COPY environment.yml bundled_pip_dependencies* /bento/ |
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.
there is no need to copy environment.yml
right?
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.
bundled_pip_dependencies
is only used for BentoML development - for installing local build of BentoML itself. This change will not benefit the end-user, nor the BentoML developers because the build cache will be invalidated if you are editing the BentoML source code.
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.
there is no need to copy environment.yml right?
We need it because bundled_pip_dependencies
may not exist. This prevents the COPY command from failing.
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.
bundled_pip_dependencies is only used for BentoML development - for installing local build of BentoML itself. This change will not benefit the end-user, nor the BentoML developers because the build cache will be invalidated if you are editing the BentoML source code.
I'm aware of that. You will find it actually benefits when bundled_pip_dependencies
exist. Also, the main purpose of this PR is to make sure that the artifact coping is in the top layer.
Motivation and Context
Slack thread:
There are two ways to achieve this:
For [1], the hot-updating of weights highly relies on frameworks' API. Since
bentoml
supports more than just one framework, it's not consistent to just support some of them.And [2] is hardly the same as:
And also, model files are not bigger than so-called weights much. In fact, weights account for 99% of the size of a saved model.
Take TensorFlow saved model as an example. There are
saved_model
andcheckpoint
for tf official docs:Try to save a tf model as both of them, you will find them hardly the same on size (the difference is about 100K).
Therefore I think leaving saved models (artifacts) as a separate layer is enough.
Description
Make the copy operation of artifacts (models in most cases) the last step in the docker build, thereby saving artifacts as a separate layer.
Also reduced image size by calling
conda clean --all
inbentoml-init.sh
A docker image of a typical MNIST classifier service by this change. The artifacts coping is in the top layer 98e5920dc1c2 now. This layer is small enough.
How Has This Been Tested?
Tested with an MNIST classifier example.
It only takes a few seconds to build newly trained models into docker images now (if the requirements don't change).
Types of changes
Component(s) if applicable
Checklist:
./dev/format.sh
and./dev/lint.sh
script have passed(instructions).