unload xformers when not used

This commit is contained in:
Vladimir Mandic
2023-04-18 07:47:41 -04:00
parent d69738cc07
commit 86783d164c
7 changed files with 59 additions and 13 deletions
+1 -1
View File
@@ -130,7 +130,7 @@ The launcher can perform automatic update of main repository, requirements, exte
Check is performed on each startup and missing requirements are auto-installed, can be skipped with `--skip-requirements` flag
- Extensions and submodules:
Update is performed on each startup and installer for each extension is started, can be skipped with `--skip-extensions` flag
- All checks can be skipped using `--quick` flag
- If timestamp of last sucessful setup is newer than actual repository version or version of newest extension, launcher will run in *quick* mode
<br>
+48 -5
View File
@@ -1,20 +1,19 @@
# TODO
## Always-on
- Pick & merge PRs from main repo
## Fixes
## Issues
Stuff to be fixed...
- Fix integration with <https://github.com/kohya-ss/sd-webui-additional-networks>
- Fix integration with <https://github.com/deforum-art/deforum-for-automatic1111-webui>
- Reconnect UI to ops in progress on browser restart
- Create new GitHub hooks/actions for CI/CD
- Remove `models` from git repo
## Features
Stuff to be added...
- Redo Extensions tab: see <https://vladmandic.github.io/sd-extension-manager/pages/extensions.html>
- Stream-load models as option for slow storage
- Replace **PngInfo** / **EXIF** metadata handler
@@ -24,8 +23,52 @@ Stuff to be fixed...
## Investigate
Stuff to be investigated...
- Revisit `torch.compile`
## Merge PRs
Pick & merge PRs from main repo...
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/7595>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8608>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8611>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8665>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8741>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8742>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9128>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9134>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9155>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9177>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9211>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9212>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9219>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9227>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9249>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9256>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9258>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9295>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9312>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9314>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9315>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9319>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9392>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9407>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9451>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9491>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9504>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9513>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9542>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9592>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9628>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9669>
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9677>
Complete:
- <https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8945>
## Integration
Tech that can be integrated as part of the core workflow...
+3 -1
View File
@@ -1,3 +1,4 @@
import sys
import html
import threading
import time
@@ -51,7 +52,8 @@ def wrap_gradio_call(func, extra_outputs=None, add_stats=False):
if run_memmon:
shared.mem_mon.monitor()
t = time.perf_counter()
if sys.modules['xformers'] is not None and shared.opts.cross_attention_optimization != "xFormers":
sys.modules["xformers"] = None
try:
if shared.cmd_opts.profile:
pr = cProfile.Profile()
+1
View File
@@ -1,3 +1,4 @@
import sys
from types import MethodType
from rich import print # pylint: disable=redefined-builtin
import torch
+4 -4
View File
@@ -88,7 +88,7 @@ def installed(package, friendly: str = None):
# install package using pip if not already installed
def install(package, friendly: str = None):
def install(package, friendly: str = None, ignore: bool = False):
def pip(arg: str):
log.debug(f"Running pip: {arg}")
result = subprocess.run(f'"{sys.executable}" -m pip {arg}', shell=True, check=False, env=os.environ, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -96,7 +96,7 @@ def install(package, friendly: str = None):
if len(result.stderr) > 0:
txt += ('\n' if len(txt) > 0 else '') + result.stderr.decode(encoding="utf8", errors="ignore")
txt = txt.strip()
if result.returncode != 0:
if result.returncode != 0 and not ignore:
global errors # pylint: disable=global-statement
errors += 1
log.error(f'Error running pip with args: {arg}')
@@ -201,9 +201,9 @@ def install_packages():
install(clip_package, 'clip')
try:
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.17')
install(f'--no-deps {xformers_package}')
install(f'--no-deps {xformers_package}', ignore=True)
except Exception as e:
log.error(f'Cannot install xformers package: {e}')
log.debug(f'Cannot install xformers package: {e}')
# clone required repositories