Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
df40d4f3
Commit
df40d4f3
authored
Feb 09, 2023
by
comfyanonymous
Browse files
torch.cuda.OutOfMemoryError is not present on older pytorch versions.
parent
1d9ec62c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
comfy/ldm/modules/sub_quadratic_attention.py
comfy/ldm/modules/sub_quadratic_attention.py
+6
-1
No files found.
comfy/ldm/modules/sub_quadratic_attention.py
View file @
df40d4f3
...
@@ -19,6 +19,11 @@ from typing import Optional, NamedTuple, Protocol, List
...
@@ -19,6 +19,11 @@ from typing import Optional, NamedTuple, Protocol, List
from
torch
import
Tensor
from
torch
import
Tensor
from
typing
import
List
from
typing
import
List
try
:
OOM_EXCEPTION
=
torch
.
cuda
.
OutOfMemoryError
except
:
OOM_EXCEPTION
=
Exception
def
dynamic_slice
(
def
dynamic_slice
(
x
:
Tensor
,
x
:
Tensor
,
starts
:
List
[
int
],
starts
:
List
[
int
],
...
@@ -151,7 +156,7 @@ def _get_attention_scores_no_kv_chunking(
...
@@ -151,7 +156,7 @@ def _get_attention_scores_no_kv_chunking(
try
:
try
:
attn_probs
=
attn_scores
.
softmax
(
dim
=-
1
)
attn_probs
=
attn_scores
.
softmax
(
dim
=-
1
)
del
attn_scores
del
attn_scores
except
torch
.
cuda
.
OutOfMemoryError
:
except
OOM_EXCEPTION
:
print
(
"ran out of memory while running softmax in _get_attention_scores_no_kv_chunking, trying slower in place softmax instead"
)
print
(
"ran out of memory while running softmax in _get_attention_scores_no_kv_chunking, trying slower in place softmax instead"
)
torch
.
exp
(
attn_scores
,
out
=
attn_scores
)
torch
.
exp
(
attn_scores
,
out
=
attn_scores
)
summed
=
torch
.
sum
(
attn_scores
,
dim
=-
1
,
keepdim
=
True
)
summed
=
torch
.
sum
(
attn_scores
,
dim
=-
1
,
keepdim
=
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment