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

feat: latest torch/comfyui; perf improvments; fix: SSL cert issues #309

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
66f2cd3
fix: don't run image.save() twice
tazlin Oct 3, 2024
10386d9
feat: use torch 2.4.1 and cu124 by default
tazlin Oct 1, 2024
42e2bf4
feat: use latest horde deps w/ latest comfyui+fixes
tazlin Oct 3, 2024
f1b80da
build/fix: condense and update dockerfiles
tazlin Oct 3, 2024
de071ce
chore: version bump
tazlin Oct 3, 2024
ddc4d78
fix: pop more often with threads>1
tazlin Oct 4, 2024
624282c
fix: wait less time w/ high perf. mode
tazlin Oct 4, 2024
1befebb
fix: dont pause at all for short jobs on high perf mode
tazlin Oct 4, 2024
6be6715
fix: wait even less w/ high perf mode
tazlin Oct 4, 2024
925e111
docs/fix: clarify certain stats/config in logs and docstrings
tazlin Oct 4, 2024
15682bc
fix: use sqrt as intended
tazlin Oct 4, 2024
d662404
fix: exit(1) on compvis model dl failure
tazlin Oct 2, 2024
c0b401e
fix: use a `certifi` ssl context for r2 uploads
tazlin Oct 2, 2024
7fe8794
fix: don't concurrently preload more than 1 model
tazlin Oct 4, 2024
683b1ca
fix: don't spam preload delay messages
tazlin Oct 4, 2024
e73fcfb
fix: include conditional to not spam delay messages
tazlin Oct 4, 2024
bbc99c7
fix: give models a chance to load before failing
tazlin Oct 4, 2024
9aaf862
fix: correct version pins across dep files
tazlin Oct 4, 2024
155820c
fix: use latest horde model reference
tazlin Oct 4, 2024
17f5099
style: fix
tazlin Oct 4, 2024
cfc62eb
fix: better deadlock detection when all procs. aren't busy
tazlin Oct 4, 2024
0c54357
fix: be slightly less aggressive w/ pops w/ high perf/threads
tazlin Oct 4, 2024
d2f839e
fix: don't give conflicting advice about `high_memory_mode` and threads
tazlin Oct 4, 2024
6d397e6
chore: log a message to see if inf. proc. `preload_models` is called
tazlin Oct 4, 2024
ced9ced
fix: don't suggest `high_memory_mode` with <=32 sys ram
tazlin Oct 4, 2024
a9a06be
fix: avoid killing all processes before jobs are finished
tazlin Oct 4, 2024
6c106ca
chore: version bump
tazlin Oct 4, 2024
7bef6fe
fix: micromamba updated cli syntax for update-runtime
tazlin Oct 4, 2024
c01927f
fix: conflicting torchvision dep in update runtime
tazlin Oct 4, 2024
e52b354
fix: flag ending processes correctly
tazlin Oct 4, 2024
107aa96
fix: correctly download via `load_large_models`
tazlin Oct 5, 2024
5e203d9
fix: docker installed python deps
HPPinata Oct 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ repos:
- python-dotenv
- aiohttp
- horde_safety==0.2.3
- torch==2.3.1
- torch==2.4.1
- ruamel.yaml
- horde_engine==2.15.3
- horde_sdk==0.14.11
- horde_model_reference==0.9.0
- horde_engine==2.16.0
- horde_sdk==0.15.1
- horde_model_reference==0.9.1
- semver
13 changes: 7 additions & 6 deletions Dockerfiles/Dockerfile.12.1.1-22.04
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
python3-venv \
python3.11-dev \
python3.11-venv \
python3.11-distutils \
libgl1 \
git

RUN git clone https://github.com/Haidra-Org/horde-worker-reGen.git && \
cd /horde-worker-reGen && \
python3.11 -m pip install --upgrade pip && \
python3 -m venv venv && \
python3.11 -m venv venv && \
. venv/bin/activate && \
python -m pip install --upgrade pip && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu121 && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu124 && \
python -m pip install opencv-python-headless -U && \
python -m pip cache purge

RUN apt-get update && apt-get install libgl1 -y

CMD cd /horde-worker-reGen && \
git pull && \
. venv/bin/activate && \
Expand Down
13 changes: 7 additions & 6 deletions Dockerfiles/Dockerfile.12.2.2-22.04
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
python3-venv \
python3.11-dev \
python3.11-venv \
python3.11-distutils \
libgl1 \
git

RUN git clone https://github.com/Haidra-Org/horde-worker-reGen.git && \
cd /horde-worker-reGen && \
python3.11 -m pip install --upgrade pip && \
python3 -m venv venv && \
python3.11 -m venv venv && \
. venv/bin/activate && \
python -m pip install --upgrade pip && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu121 && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu124 && \
python -m pip install opencv-python-headless -U && \
python -m pip cache purge

RUN apt-get update && apt-get install libgl1 -y

CMD cd /horde-worker-reGen && \
git pull && \
. venv/bin/activate && \
Expand Down
13 changes: 7 additions & 6 deletions Dockerfiles/Dockerfile.12.3.2-22.04
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
python3-venv \
python3.11-dev \
python3.11-venv \
python3.11-distutils \
libgl1 \
git

RUN git clone https://github.com/Haidra-Org/horde-worker-reGen.git && \
cd /horde-worker-reGen && \
python3.11 -m pip install --upgrade pip && \
python3 -m venv venv && \
python3.11 -m venv venv && \
. venv/bin/activate && \
python -m pip install --upgrade pip && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu121 && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu124 && \
python -m pip install opencv-python-headless -U && \
python -m pip cache purge

RUN apt-get update && apt-get install libgl1 -y

CMD cd /horde-worker-reGen && \
git pull && \
. venv/bin/activate && \
Expand Down
31 changes: 31 additions & 0 deletions Dockerfiles/Dockerfile.12.4-22.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get install -y --no-install-recommends \
python3.11 \
python3-pip \
python3.11-dev \
python3.11-venv \
python3.11-distutils \
libgl1 \
git

RUN git clone https://github.com/Haidra-Org/horde-worker-reGen.git && \
cd /horde-worker-reGen && \
python3.11 -m venv venv && \
. venv/bin/activate && \
python -m pip install --upgrade pip && \
python -m pip install -r /horde-worker-reGen/requirements.txt -U --extra-index-url https://download.pytorch.org/whl/cu124 && \
python -m pip install opencv-python-headless -U && \
python -m pip cache purge

CMD cd /horde-worker-reGen && \
git pull && \
. venv/bin/activate && \
python -m pip install -r requirements.txt -U && \
python download_models.py -e && \
python run_worker.py -e
2 changes: 1 addition & 1 deletion README_advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
### Get worker files and install dependencies
- `git clone https://github.com/Haidra-Org/horde-worker-reGen.git`
- `cd .\horde-worker-reGen\`
- `pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121`
- `pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu124`

### Run worker
- Set your config now, copying `bridgeData_template.yaml` to `bridgeData.yaml`, being sure to set an API key and worker name at a minimum
Expand Down
4 changes: 4 additions & 0 deletions bridgeData_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ unload_models_from_vram_often: true
# 12GB-16GB VRAM: false
# 8GB-10GB VRAM: true

# Normally only one model will load off disk at a time. Set to true to load multiple models at once.
# This requires a very fast disk. You will see a sharp increase in disk usage, especially with SDXL/Cascade/Flux/other large models.
very_fast_disk_mode: false

# List of words to reject if they appear in the prompt.
blacklist: []

Expand Down
2 changes: 1 addition & 1 deletion horde-bridge.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cd /d %~dp0
call runtime python -s -m pip -V

call python -s -m pip uninstall hordelib
call python -s -m pip install horde_sdk~=0.14.11 horde_model_reference~=0.9.0 horde_engine~=2.15.3 horde_safety~=0.2.3 -U
call python -s -m pip install horde_sdk~=0.15.1 horde_model_reference~=0.9.1 horde_engine~=2.16.0 horde_safety~=0.2.3 -U

if %ERRORLEVEL% NEQ 0 (
echo "Please run update-runtime.cmd."
Expand Down
2 changes: 1 addition & 1 deletion horde_worker_regen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ASSETS_FOLDER_PATH = Path(__file__).parent / "assets"

__version__ = "9.0.7"
__version__ = "9.1.1"


import pkg_resources # noqa: E402
Expand Down
2 changes: 1 addition & 1 deletion horde_worker_regen/_version_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"recommended_version": "9.0.7",
"recommended_version": "9.1.1",
"required_min_version": "9.0.2",
"required_min_version_update_date": "2024-09-26",
"required_min_version_info": {
Expand Down
3 changes: 3 additions & 0 deletions horde_worker_regen/bridge_data/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class reGenBridgeData(CombinedHordeBridgeData):
moderate_performance_mode: bool = Field(default=False)
"""If you have a 3080 or better, set this to true to enable moderate performance mode."""

very_fast_disk_mode: bool = Field(default=False)
"""If you have a very fast disk, set this to true to concurrently load more models at a time from disk."""

post_process_job_overlap: bool = Field(default=False)
"""High and moderate performance modes will skip post processing if this is set to true."""

Expand Down
5 changes: 5 additions & 0 deletions horde_worker_regen/load_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def load_env_vars_from_config() -> None: # FIXME: there is a dynamic way to do
)
os.environ["AI_HORDE_URL"] = custom_horde_url

if "load_large_models" in config and os.getenv("AI_HORDE_MODEL_META_LARGE_MODELS") is None:
config_value = config["load_large_models"]
if config_value is True:
os.environ["AI_HORDE_MODEL_META_LARGE_MODELS"] = "1"


if __name__ == "__main__":
load_env_vars_from_config()
Expand Down
10 changes: 4 additions & 6 deletions horde_worker_regen/process_management/inference_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import base64
import contextlib
import io
import sys
import time

Expand Down Expand Up @@ -352,13 +351,14 @@ def preload_model(
seamless_tiling_enabled (bool): Whether or not seamless tiling is enabled.
job_info (ImageGenerateJobPopResponse): The job to preload the model for.
"""
logger.debug(f"Currently active model is {self._active_model_name}. Requested model is {horde_model_name}")

if self._active_model_name == horde_model_name:
return

if self._is_busy:
logger.warning("Cannot preload model while busy")

logger.debug(f"Currently active model is {self._active_model_name}")
logger.debug(f"Preloading model {horde_model_name}")

if self._active_model_name is not None:
Expand Down Expand Up @@ -585,13 +585,11 @@ def send_inference_result_message(

if results is not None:
for result in results:
buffered_image = io.BytesIO()
if result.image is None:
if result.rawpng is None:
logger.critical("Result or result image is None")
continue

result.image.save(buffered_image, format="PNG")
image_base64 = base64.b64encode(buffered_image.getvalue()).decode("utf-8")
image_base64 = base64.b64encode(result.rawpng.getvalue()).decode("utf-8")
all_image_results.append(
HordeImageResult(
image_base64=image_base64,
Expand Down
Loading
Loading