Skip to content

Commit

Permalink
Merge branch 'release_candidate'
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Aug 23, 2023
2 parents 68f336b + 31f2be3 commit c9c8485
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.5.2

### Bug Fixes:
* fix memory leak when generation fails
* update doggettx cross attention optimization to not use an unreasonable amount of memory in some edge cases -- suggestion by MorkTheOrk


## 1.5.1

### Minor:
Expand Down
4 changes: 3 additions & 1 deletion modules/call_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
import time

from modules import shared, progress, errors
from modules import shared, progress, errors, devices

queue_lock = threading.Lock()

Expand Down Expand Up @@ -75,6 +75,8 @@ def f(*args, extra_outputs_array=extra_outputs, **kwargs):
error_message = f'{type(e).__name__}: {e}'
res = extra_outputs_array + [f"<div class='error'>{html.escape(error_message)}</div>"]

devices.torch_gc()

shared.state.skipped = False
shared.state.interrupted = False
shared.state.job_count = 0
Expand Down
3 changes: 2 additions & 1 deletion modules/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def record_exception():
if exception_records and exception_records[-1] == e:
return

exception_records.append((e, tb))
from modules import sysinfo
exception_records.append(sysinfo.format_exception(e, tb))

if len(exception_records) > 5:
exception_records.pop(0)
Expand Down
4 changes: 2 additions & 2 deletions modules/sd_hijack_optimizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ def split_cross_attention_forward(self, x, context=None, mask=None, **kwargs):
raise RuntimeError(f'Not enough memory, use lower resolution (max approx. {max_res}x{max_res}). '
f'Need: {mem_required / 64 / gb:0.1f}GB free, Have:{mem_free_total / gb:0.1f}GB free')

slice_size = q.shape[1] // steps if (q.shape[1] % steps) == 0 else q.shape[1]
slice_size = q.shape[1] // steps
for i in range(0, q.shape[1], slice_size):
end = i + slice_size
end = min(i + slice_size, q.shape[1])
s1 = einsum('b i d, b j d -> b i j', q[:, i:end], k)

s2 = s1.softmax(dim=-1, dtype=q.dtype)
Expand Down
6 changes: 5 additions & 1 deletion modules/sysinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ def format_traceback(tb):
return [[f"{x.filename}, line {x.lineno}, {x.name}", x.line] for x in traceback.extract_tb(tb)]


def format_exception(e, tb):
return {"exception": str(e), "traceback": format_traceback(tb)}


def get_exceptions():
try:
from modules import errors

return [{"exception": str(e), "traceback": format_traceback(tb)} for e, tb in reversed(errors.exception_records)]
return list(reversed(errors.exception_records))
except Exception as e:
return str(e)

Expand Down

0 comments on commit c9c8485

Please sign in to comment.