-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Optimized Docker build with support for external working directory #1544
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
Conversation
thank you very much for this. i am a docker noob, is it expected that this fails to run on mac?
|
same here on MacBook Air M1
|
@damian0815 sorry if I already asked this, do you have M1 as well? |
yes i do! |
Then I guess it would be buildable by f.e. do a |
@ebr unfortunately this fails runpod - which is to be expected in fact:
on runpod there's no way to provide a pre-populated persistent storage, and if the docker image itself doesn't actually launch an openssh server, no way to connect to it to do that after the image is launched. and at the moment there's no way to configure InvokeAI from the web server alone. this is i think something we need to add but it is not yet on the roadmap. |
normaly you should do the setup of the local volume via a sidecar container (when working in K8s which |
@ebr to make this usable for invoke as-is you'd need to
|
besides that you could mount a blob storage or network storage wich has been preloaded (but I like the Sidecar way more since I like automation ;P ) |
is network storage feasible given the amount of data involved? the i mean, i have images i've kept mounted (but stopped) for over a month now, just because they have like 15 GB of model files on them and i don't want to sit around re-downloading all of that again |
a dscription what sidecar containers are: https://www.containiq.com/post/kubernetes-sidecar-container I do not know |
depending on where and how you want to host the container, a network storage can of course be a valid option to do so xD (I don't see the difference if I use a Blob Storage, a Network Storage, or any other kind of persistent storage which needs to be mounted to the container....) |
the screenshot above is the entirety of the configuration options i have access to using the runpod web ui |
like I sayed, this is only a pod configuration. I think you did not look into the description what a sidecar container is, so TLDR: It is another Pod which f.e. can run before running the "main pod", which then could f.e. run the |
<math lady.gif> well it turns out that i can in fact start the instance, stop it, change the docker image, and start it again. is that what you mean? i don't think i have any other way of sharing persistent storage between two different docker images. so you're suggesting i should make another dockerfile which builds a python environment with the dependencies for |
@ebr in fact it turns out i would like to be able to do this: but it seems your dockerfile ignores this and runs invokeai.py instead. i read about this somewhere, something about setting ENTRYPOINT vs setting CMD ..? |
What I suggested is to read https://www.containiq.com/post/kubernetes-sidecar-container ;P |
|
@mauwii @damian0815 thank you both for the review and testing! Let me see if I can cover all comments:
I'll sink my teeth into Runpod now and report back. |
Well, after the K8s Trainings I atended I cannot say that sidecars are inefficent, of course they can be, but when used clever they can be very efficent and save you lot of work ;) for example to check if updated code is available and pull if yes, or create backups on the fly, .... many reasons to use sidecars :P |
I only mean they are inefficient for this specific application (maintaining an external, shared model cache that needs to exist beyond the lifecycle of a pod), because if you have multiple pods using the same template, then the sidecars will experience race conditions and unnecessarily thrash both remote and local storage. This is much better handled by a daemonset. But yes, sidecars certainly have many great uses! In case of invokeai running on k8s, a sidecar might be useful for periodically syncing an instance's output results to S3, given each instance is running in its own pod. Depends on the design. I think with the upcoming changes to the API this will need some re-thinking. But this is quite offtopic for the current PR (I'd love to continue the convo elsewhere/another time though!) |
So in my current container I mount a volume to /data where all of the models and outputs are stored, don't see a reason why this volume should not be able to be shared between more pods. you can of course also mount a storage which is preloaded with the models and dont use the sidecar, but advantage of the sidecar to update the models when invokeai gets another update is prety obvious to me 🙈 |
so, (again, offtopic 😉 but i can't help being baited by k8s talk): consider a case where multiple application pods are running on a multi-GPU node, and each such pod includes the sidecar. Yes, all pods will have access to the |
Why would I include the sidecar in the pod - the sidecar is a seperate pod, called via a cronjob?! since we are here in an invoke-ai PR, I like to think about the usecase for a sidecar to be used with the invokeai manifest ;P and no, I mean having one storage for persistence, maybe per node, but not per pod. |
a sidecar is, by definition, a container that runs inside the same pod next to the "primary" container :) (but there's nothing that inherently makes a container a "sidecar" or "primary" - they are equal from the pod design standpoint). If you're talking about a cronjob, then no, it's not a sidecar (plus you'd need to deal with some anti-affinity rules to ensure that only one pod of the cronjob runs on each node, to avoid conflicts). We can perhaps discuss this elsewhere. If you have any k8s questions, I'll be glad to answer them :) it might be easier to discuss once I push my k8s manifests for deploying a complete solution. But I'm thinking of packaging them as a Helm chart first, for flexibility. (and yes, by "application" I only mean InvokeAI; just used to talking in general terms when designing infrastructure) |
https://www.containiq.com/post/kubernetes-sidecar-container Share same pod? how can one pod have more entrypoints? Well, nevermind .... |
In brief: a pod is comprised of one or more containers. Each container has its own entrypoint, args, environment, etc. containers share the network namespace, and they may cross-mount volumes that are defined in the pod spec. Multiple containers run in a pod. Usually one is designated as the main workload container, and the others are "sidecars". Anyway, like I said, I don't think this is the place to argue about this. With all due respect, please feel free to check my LinkedIn if you're not yet fully convinced I know what I'm talking about, and I'd be more than happy to offer you a tutorial elsewhere if you have any questions at all about k8s stuff 😄 ... With that out of the way: I just added one commit, and the latest image works wonderfully on Runpod (including initializing and using external storage mounted at |
This is now rebased on |
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.
looks good to me
I can merge this if there are no objections. However, the CI tests are stalled in the "Expected, waiting for reporting" state. I've seen this happen occasionally, and I think someone needs to push a trivial change in order to trigger them.
L
On Mon, Dec 5, 2022 at 8:00 AM Matthias Wild ***@***.***> wrote:
@ebr <https://github.com/ebr> @mauwii <https://github.com/mauwii> is
anything blocking this? can we just merge it? would love to have an
official top-level docker image i can just pull to get latest on runpod..
My aproval is still valid, isn't it?
—
Reply to this email directly, view it on GitHub
<#1544 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA3EVK7P44RGGCXGQA4AULWLXRPXANCNFSM6AAAAAASJX6N5E>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Written on my cell phone. Anything that seems odd is the fault of
auto-correct.
|
@ebr would have done so, but since it is hosted in your fork this can only be done by you 🙈 |
useful for cloud deployments. attempts to utilize docker layer caching as effectively as possible. also some quick tools to help with building
…ding the cmd if needed (e.g. in Runpod
I just rebased it on latest main - hope this gets CI unstuck! |
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.
giving this another review to try get the workflows unstuck.
Maybe this is a side effect since rebased from development to main.
But since this does not change any files related to the workflows it could imho be merged without the actions succeeding.
So Actions still have been stuck and since @lstein also agreed earlier that he would merge it, I just went ahead now 🙈 |
What this does
Dockerfile.cloud
intended for use with remote deployments. Extensively tested on Linux (x86_64 / CUDA), but not macOS or Windows. (Hence a new Dockerfile.cloud, to avoid surprises to users of current docker setup).pytorch
). Utilizes docker build-time cache and multi-stage builds. Requires Docker Buildkit for caching (DOCKER_BUILDKIT=1
).INVOKEAI_ROOT
which contains models, config, etc) is expected to be mounted into the container, allowing for seamless upgrades with no data lossghcr.io/invokeai
image. Github actions and package storage are free for open-source projects. Because no models are bundled, this is compliant with existing licensing and may be freely publicised and distributed.Use this on Runpod
Try this template: https://runpod.io/gsc?template=vm19ukkycf&ref=mk65wpsa (should be self-explanatory - see README 😆)
At a high-level:
Testing/usage locally (Linux only right now!):
PR includes a
Makefile
for easy building/running/demo purpose. If desirable, this can be easily rewritten as a shell script ordocker-compose
.cd docker-build
make build
make configure
(the usual configuration flow will be executed, including the prompt for HF token)make cli
ormake web
http://localhost:9090
~/invokeai
directory which will be populated with the expectedINVOKEAI_ROOT
contentsCaveats
Some files in the runtime dir (e.g. outputs) may be owned by the root user. A fix for this is upcoming; in the meantime
sudo chown -R $(id -u):$(id -g) ~/invokeai
can be used to fix ownership