From dae07f596e5b50b6b9dc7914c83b5687901e287b Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 14 Jan 2023 11:12:31 -0500 Subject: [PATCH] update --- README.md | 4 ++-- TODO.md | 10 ++++++---- automatic.sh | 4 ++-- cli/xformers.sh | 12 ++++++++++++ config.json | 7 +++++-- extensions-builtin/info-tab/scripts/info-tab.py | 6 ++++++ modules/sd_hijack.py | 9 +++++++++ 7 files changed, 42 insertions(+), 10 deletions(-) create mode 100755 cli/xformers.sh diff --git a/README.md b/README.md index 2c97f43b4..f424a9291 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ Fork does differ in few things: Only Python library which is not auto-updated is `PyTorch` itself as that is very system specific I'm currently using **PyTorch 2.0-nightly** compiled with **CUDA 11.8** and with **Triton** optimizations: -> pip3 install --pre torch torchvision torchaudio torchtriton --extra-index-url https://download.pytorch.org/whl/nightly/cu118 +> pip3 install --pre torch torchvision torchaudio torchtriton --extra-index-url https://download.pytorch.org/whl/nightly/cu118 --force > pip show torch -> 2.0.0.dev20230111+cu118 +> 2.0.0.dev20230113+cu118
diff --git a/TODO.md b/TODO.md index f701cd589..8d52a4bf2 100644 --- a/TODO.md +++ b/TODO.md @@ -31,7 +31,6 @@ Things I'm looking into... Stuff to be fixed... -- Model switch memory leak - Torch 2.0 model compile Tech that can be integrated as part of the core workflow... @@ -62,6 +61,11 @@ Cool stuff that is not integrated anywhere... - [Disco Diffusion](https://colab.research.google.com/github/alembics/disco-diffusion/blob/main/Disco_Diffusion.ipynb) - [Video Killed the Radio Star](https://colab.research.google.com/github/dmarx/video-killed-the-radio-star/blob/main/Video_Killed_The_Radio_Star_Defusion.ipynb) +# SDAPI + +- Support TLS +- Support auth + # External Ideas that can be value-added to core tech... @@ -69,9 +73,7 @@ Ideas that can be value-added to core tech... - Prevalent colors to interrogate - Auto-Sort inputs by face recognition - Use semantic segmentation to remove background from inputs -- Auto-filter training inputs based - Auto-filter training inputs based on blur -if shared.opts.training_enable_tensorboard and shared.opts.training_tensorboard_save_images: -clip_grad_mode \ No newline at end of file +/home/vlado/dev/sd-extensions/api/losschart.py:48: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`. \ No newline at end of file diff --git a/automatic.sh b/automatic.sh index ea3aa31b0..fbe69d064 100755 --- a/automatic.sh +++ b/automatic.sh @@ -1,5 +1,5 @@ #/bin/env bash export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 -python launch.py --api --disable-console-progressbars -# python launch.py --api --xformers --disable-console-progressbars --opt-channelslast +python launch.py --api --xformers --disable-console-progressbars +# python launch.py --api --disable-console-progressbars --opt-channelslast diff --git a/cli/xformers.sh b/cli/xformers.sh new file mode 100755 index 000000000..c7073999f --- /dev/null +++ b/cli/xformers.sh @@ -0,0 +1,12 @@ +#/bin/env bash +echo "Installing xformers" + +NVCC_FLAGS="--use_fast_math" +FORCE_CUDA="1" +TORCH_CUDA_ARCH_LIST="8.6" +pip install ninja -q +pip uninstall xformers -y 2>/dev/null +pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers +pip show torch +pip show xformers +python -m xformers.info diff --git a/config.json b/config.json index f80c29102..779275789 100644 --- a/config.json +++ b/config.json @@ -56,7 +56,7 @@ "training_image_repeats_per_epoch": 1, "training_write_csv_every": 10.0, "training_xattention_optimizations": false, - "sd_model_checkpoint": "zeipher-f222.ckpt [44bf0551]", + "sd_model_checkpoint": "sd-v15-runwayml.ckpt [81761151]", "sd_checkpoint_cache": 0, "sd_vae": "vae-ft-mse-840000-ema-pruned", "sd_vae_as_default": false, @@ -153,5 +153,8 @@ "always_discard_next_to_last_sigma": false, "clip_models_path": "models/CLIP", "save_training_settings_to_txt": true, - "use_old_hires_fix_width_height": false + "use_old_hires_fix_width_height": false, + "training_enable_tensorboard": true, + "training_tensorboard_save_images": true, + "training_tensorboard_flush_every": 60.0 } \ No newline at end of file diff --git a/extensions-builtin/info-tab/scripts/info-tab.py b/extensions-builtin/info-tab/scripts/info-tab.py index 528e335d7..d9f9b1c95 100644 --- a/extensions-builtin/info-tab/scripts/info-tab.py +++ b/extensions-builtin/info-tab/scripts/info-tab.py @@ -30,6 +30,10 @@ def get_cuda(): except Exception as e: return { 'error': e } +def get_uptime(): + s = vars(shared.state) + return time.strftime('%c', time.localtime(s.get('server_start', time.time()))) + def get_state(): s = vars(shared.state) flags = 'skipped ' if s.get('skipped', False) else '' @@ -193,6 +197,7 @@ def get_full_data(): data = { 'date': datetime.datetime.now().strftime('%c'), 'timestamp': datetime.datetime.now().strftime('%X'), + 'uptime': get_uptime(), 'version': get_version(), 'model': get_model(), 'vae': get_vae(), @@ -247,6 +252,7 @@ def on_ui_tabs(): with gr.Box(): with gr.Row(): with gr.Column(): + gr.Textbox(data['uptime'], label = 'Server start time', lines = 1) gr.Textbox(dict2text(data['version']), label = 'Version', lines = len(data['version'])) with gr.Column(): model = gr.Textbox(dict2text(data['model']), label = 'Model', lines = len(data['model'])) diff --git a/modules/sd_hijack.py b/modules/sd_hijack.py index 6b0d95af9..57fb8466f 100644 --- a/modules/sd_hijack.py +++ b/modules/sd_hijack.py @@ -103,6 +103,15 @@ class StableDiffusionModelHijack: m.cond_stage_model.model.token_embedding = EmbeddingsWithFixes(m.cond_stage_model.model.token_embedding, self) m.cond_stage_model = sd_hijack_open_clip.FrozenOpenCLIPEmbedderWithCustomWords(m.cond_stage_model, self) + try: + import time + t0 = time.time() + m = torch.compile(m, mode="max-autotune", fullgraph=True) + t1 = time.time() + print(f"Model compiled in {round(t1 - t0, 2)} sec") + except Exception as err: + print(f"Model compile not supported: {err}") + self.optimization_method = apply_optimizations() self.clip = m.cond_stage_model