Skip to content

Conversation

@ebr
Copy link
Contributor

@ebr ebr commented Nov 14, 2022

What this does

  • Initially intended/tested for cloud deployments, further adapted for local use
  • Can be used locally on CUDA-capable systems. The only dependencies are docker with the nvidia runtime, and make for convenience. (e.g. not even a local python is required). Fully tested on Linux only (Ubuntu 22.04/CUDA 11.7). Will most likely work on Windows/WSL2.
  • Significant optimizations to Docker build:
    • No git clone happens inside docker build - only context is used
    • Attempts to utilize docker layer cache as efficiently as possible by splitting out local package installation
    • reduces image size by at least 2GB compared to the current Docker x86_64 image, might be possible to optimize further.
  • Supports the latest unified caching mechanism specified by $INVOKE_ROOT or --root options
  • Includes a Makefile for easy building/running (was quick to throw together, but it can be easily rewritten as bash or docker-compose, as this is currently not used in the project)
  • adds Github actions for automated image building and pushing, ready for use with e.g. an existing INVOKE_ROOT cache on a cloud runner. No special privileges or secrets are required for image build/push.

Testing/usage:

  • cd docker-build
  • make load-models (Huggingface token will be prompted for if not already set via env var)
  • make run
  • access the web UI on http://localhost:9090
  • examine the ~/invokeai directory which will be populated with the expected INVOKE_ROOT contents

This PR does not touch any existing local docker setup to avoid surprises to existing users, except un-ignoring some paths from .dockerignore at build time. Should have no practical effect on existing users. But it can easily and optimally replace the existing docker setup. Future work can replace Makefile with docker-compose, if desirable.

@mauwii
Copy link
Contributor

mauwii commented Nov 14, 2022

Does the CUDA Image work for ATI as well?

@ebr
Copy link
Contributor Author

ebr commented Nov 14, 2022

Do you mean AMD? i have no way to test, but I doubt it will, since AMD doesn't use CUDA...

@mauwii
Copy link
Contributor

mauwii commented Nov 14, 2022

Yes, ment AMD, sorry, old man sitting here xD

@ebr
Copy link
Contributor Author

ebr commented Nov 14, 2022

No worries, that's how I also knew what you meant 👴 ;)

@ebr ebr marked this pull request as draft November 14, 2022 10:04
@ebr ebr changed the title [draft] Minimal container image Minimal container image Nov 14, 2022
@ebr ebr marked this pull request as ready for review November 14, 2022 16:29
@ebr ebr force-pushed the docker-min branch 2 times, most recently from 76362a8 to 03421d2 Compare November 15, 2022 06:29
@damian0815
Copy link
Contributor

damian0815 commented Nov 15, 2022

ohh. any hints for making the cache rehydration work with low-tech cheap remote GPU hosts like https://runpod.io (which doesn't expose any system config other than a docker image path)?

@ebr
Copy link
Contributor Author

ebr commented Nov 16, 2022

I'm not familiar with runpod, but you should be able to run this very image with preload_models.py insead of invoke.py (take a look at the Makefile), as long as you can mount some directory or volume into the container. Basically anywhere you can run a container you should be able to do it. but maybe i'm misunderstanding your question

@damian0815
Copy link
Contributor

actually yeah that should work - thanks.

@ebr ebr marked this pull request as draft November 19, 2022 17:21
@ebr ebr changed the base branch from main to development November 19, 2022 17:22
@ebr ebr force-pushed the docker-min branch 5 times, most recently from 0ab8972 to e6a4aa4 Compare November 21, 2022 04:24
@ebr ebr marked this pull request as ready for review November 21, 2022 07:16
@ebr ebr requested a review from mauwii as a code owner November 21, 2022 07:16
@ebr
Copy link
Contributor Author

ebr commented Nov 21, 2022

@mauwii I made significant updates to the PR, rebased on latest in development, etc. Could you please take a look so it doesn't go stale/outdated. Thx

@ebr ebr changed the title Minimal container image Optimized Docker image for cloud and local use, with external model cache Nov 21, 2022
@ebr ebr force-pushed the docker-min branch 3 times, most recently from de4e86e to d4efeb5 Compare November 23, 2022 15:15
ebr added 3 commits November 23, 2022 10:19
useful for cloud deployments. attempts to utilize docker layer
caching as effectively as possible. also some quick tools to help with
building
@ebr
Copy link
Contributor Author

ebr commented Nov 24, 2022

will reopen

@ebr ebr closed this Nov 24, 2022
@mauwii
Copy link
Contributor

mauwii commented Nov 24, 2022

@mauwii I made significant updates to the PR, rebased on latest in development, etc. Could you please take a look so it doesn't go stale/outdated. Thx

Sorry, I was sick the last days and did not open my MacBook at all 🤧

@ebr
Copy link
Contributor Author

ebr commented Nov 25, 2022

no problem @mauwii, hope you're feeling better. I opened a new PR that I'm currently testing on Runpod.

@mauwii
Copy link
Contributor

mauwii commented Nov 25, 2022

I know, I already added a review which instead of lstein is no in my decission :-o

And don't feel ofenden plz, because I updated my image now as well 🙈

@ebr
Copy link
Contributor Author

ebr commented Nov 25, 2022

@mauwii I don't feel offended, no worries. It does look like some of the ideas from this PR inspired the changes in your Dockerfile, but 🙈 😄 . I'm glad it helped.

@ebr ebr mentioned this pull request Nov 25, 2022
@mauwii
Copy link
Contributor

mauwii commented Nov 25, 2022

I started this way before your PR came in, then stopped it since the Models where far away from being centralized (would need to look in my fork if I have a PR about this, but I think you won't think I am lieing anyway ;P )

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.

3 participants