-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Add docker files #1418
Add docker files #1418
Changes from 14 commits
97769de
ef5da9d
5b30983
5b30804
79ba09c
992979b
14b1acd
b68807b
45b1bdd
3af1528
ca45144
3cd3c7e
40e716b
8072641
c07de3d
854a4fd
ad9fc1e
81a45ed
ac5af9f
c37f540
17e9811
e5cc831
70a8626
19aa714
b5ccc63
416448b
1b094f3
d79de68
6d9d2b3
b05be6f
97f27c1
2c42a3e
97ac2e3
8b5b1b9
7c75e49
509a61b
66ec479
dfa4da0
b1ea926
6da2903
b32bcde
34d7617
4da6c44
ab528e1
e838927
b48ff50
6a5b5dc
6fb8f5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM nvidia/cuda:12.3.1-base-ubuntu22.04 | ||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV CMDARGS --share | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y curl libgl1 libglib2.0-0 python3-pip python-is-python3 && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY requirements_docker.txt requirements_versions.txt /tmp/ | ||
RUN pip install --no-cache-dir -r /tmp/requirements_docker.txt -r /tmp/requirements_versions.txt && \ | ||
rm -f /tmp/requirements_docker.txt /tmp/requirements_versions.txt | ||
RUN curl -fsL -o /usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2 https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_amd64 && \ | ||
chmod +x /usr/local/lib/python3.10/dist-packages/gradio/frpc_linux_amd64_v0.2 | ||
|
||
RUN adduser --disabled-password --gecos '' user && \ | ||
mkdir -p /content/app /content/data | ||
|
||
COPY . /content/app | ||
RUN chown -R user:user /content | ||
|
||
WORKDIR /content | ||
USER user | ||
|
||
RUN mv /content/app/models /content/app/models.org | ||
|
||
CMD /content/app/entrypoint.sh ${CMDARGS} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: '3.9' | ||
|
||
volumes: | ||
fooocus-data: | ||
|
||
services: | ||
app: | ||
build: . | ||
image: whitehara/fooocus | ||
ports: | ||
- 7865:7865 | ||
environment: | ||
- CMDARGS=--listen # Arguments for entry_with_update.py. | ||
- DATADIR=/content/data # Directory which stores models and the outputs dir | ||
- config_path=/content/data/config.txt | ||
- config_example_path=/content/data/config_modification_tutorial.txt | ||
- path_checkpoints=/content/data/models/checkpoints/ | ||
- path_loras=/content/data/models/loras/ | ||
- path_embeddings=/content/data/models/embeddings/ | ||
- path_vae_approx=/content/data/models/vae_approx/ | ||
- path_upscale_models=/content/data/models/upscale_models/ | ||
- path_inpaint=/content/data/models/inpaint/ | ||
- path_controlnet=/content/data/models/controlnet/ | ||
- path_clip_vision=/content/data/models/clip_vision/ | ||
- path_fooocus_expansion=/content/data/models/prompt_expansion/fooocus_expansion/ | ||
- path_outputs=/content/app/outputs/ # Warning: If this directory is not located under '/content/app', you can't see history log! | ||
- default_model=juggernautXL_version6Rundiffusion.safetensors | ||
- default_performance=Speed | ||
volumes: | ||
- fooocus-data:/content/data | ||
tty: true | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
device_ids: ['0'] | ||
capabilities: [compute, utility] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Fooocus on Docker | ||
|
||
It's based on NVIDIA CUDA 12.3. See [Dockerfile](Dockerfile) for details. | ||
|
||
PyTorch version is 2.1. See [requirements_docker.txt](requirements_docker.txt) for details. | ||
|
||
## Quick start | ||
|
||
**This is just an easy way for testing. Please also see [Notes](#notes) for using.** | ||
|
||
Clone git, Then run the docker container `docker compose up --build` | ||
It takes a time to build the container image. | ||
When you see a messeage `Use the app with http://localhost:7865/` in the console message, you can access the URL on your browser. | ||
|
||
Your models, outputs are stored into 'fooocus-data' volume which may be stored in '/var/lib/docker/volumes'. | ||
|
||
## Use pre-built image | ||
|
||
The pre-built image is provided at `whitehara/fooocus` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could even automate the pipeline for each main branch update (or directly optimise thr process and use Gitlab releases for that...) and tag it with the corresponding version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If someone creates an official dockerhub account, I can modify the document for that. Then, I will stop providing my images in my dockerhub account. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm doing it in my repo. Please refer my Github Actions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the drive-by comment. I hadn't noticed you were already publishing the images to dockerhub. That makes sense. It wasn't my intention to suggest adding publishing images for this repo in this PR. Although that would be great! I was just getting impatient 🤭. Thanks for your work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lllyasviel would you be willing to create a Dockerhub repository for Fooocus or shall i set it up + add the according actions to Github pushes (main) and/or releases? |
||
|
||
You can modify 'docker-compose.yml', then `docker compose up` | ||
|
||
Note: when you use the pre-built image, you need to make the 'fooocus-data' volume which permission is '777' ( all users can read/write.) before you run the container. | ||
Otherwise, you will see the permission error. | ||
|
||
## Details | ||
|
||
### Paths inside the container | ||
|
||
|Path|Details| | ||
|-|-| | ||
|/content/app|The application stored folder| | ||
|/content/app/models.org|Original 'models' folder.<br> Files are copied to the '/content/app/models' which is symlinked to '/content/data/models' every time the container boots. (Existing files will not be overwritten.) | | ||
|/content/data|Persistent volume mount point| | ||
|/content/data/models|The folder is symlinked to '/content/app/models'| | ||
|/content/data/outputs|The folder is symlinked to '/content/app/outputs'| | ||
|
||
### Environments | ||
|
||
You can change 'config.txt' parameters by using environments. | ||
**The priority of using the environments is higher than the values defined in 'config.txt'. And they will be saved to the 'config_modification_tuorial.txt'** | ||
|
||
Docker specified environments are there. They are used by 'entrypoint.sh' | ||
|Environment|Details| | ||
|-|-| | ||
|DATADIR|'/content/data' location.| | ||
|CMDARGS|Arguments for [entry_with_update.py](entry_with_update.py) which is called by [entrypoint.sh](entrypoint.sh)| | ||
|config_path|'config.txt' location| | ||
|config_example_path|'config_modification_tutorial.txt' location| | ||
|
||
You can also use the same json key names and values explained in the 'config_modification_tutorial.txt' as the environments. | ||
See samples in the [docker-compose.yml](docker-compose.yml) | ||
|
||
## Notes | ||
|
||
- Please keep 'path_outputs' under '/content/app'. Otherwise, you will see an error when you open the history log. | ||
- Docker on Mac/Windows has a slow volume access problem when you use "bind mount" volume. When you see this problem, don't use "bind mount". Please refer to [this article](https://docs.docker.com/storage/volumes/#use-a-volume-with-docker-compose) for not using "bind mount". |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
ORIGINALDIR=/content/app | ||
# Use predefined DATADIR if it is defined | ||
[[ x"${DATADIR}" == "x" ]] && DATADIR=/content/data | ||
|
||
# make persistent dir from original dir | ||
function mklink () { | ||
mkdir -p $DATADIR/$1 | ||
ln -s $DATADIR/$1 $ORIGINALDIR | ||
} | ||
|
||
cd $ORIGINALDIR | ||
|
||
# models | ||
mklink models | ||
# Copy original files | ||
(cd $ORIGINALDIR/models.org && cp -Rpn . $ORIGINALDIR/models/) | ||
|
||
# outputs | ||
mklink outputs | ||
|
||
# Start application | ||
python entry_with_update.py $* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
torch==2.1.2 | ||
torchvision==0.16.2 | ||
torchaudio==2.1.2 | ||
torchtext==0.16.2 | ||
torchdata==0.7.1 | ||
xformers==0.0.23.post1 | ||
triton==2.1.0 |
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.
I would suggest changing the image name to something more generic. Maybe plainly
fooocus
?