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
cc8baf10
Commit
cc8baf10
authored
Mar 05, 2023
by
comfyanonymous
Browse files
Make VAE use common function to get free memory.
parent
798c90e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
comfy/ldm/modules/diffusionmodules/model.py
comfy/ldm/modules/diffusionmodules/model.py
+2
-6
No files found.
comfy/ldm/modules/diffusionmodules/model.py
View file @
cc8baf10
...
@@ -7,6 +7,7 @@ from einops import rearrange
...
@@ -7,6 +7,7 @@ from einops import rearrange
from
typing
import
Optional
,
Any
from
typing
import
Optional
,
Any
from
ldm.modules.attention
import
MemoryEfficientCrossAttention
from
ldm.modules.attention
import
MemoryEfficientCrossAttention
import
model_management
try
:
try
:
import
xformers
import
xformers
...
@@ -199,12 +200,7 @@ class AttnBlock(nn.Module):
...
@@ -199,12 +200,7 @@ class AttnBlock(nn.Module):
r1
=
torch
.
zeros_like
(
k
,
device
=
q
.
device
)
r1
=
torch
.
zeros_like
(
k
,
device
=
q
.
device
)
stats
=
torch
.
cuda
.
memory_stats
(
q
.
device
)
mem_free_total
=
model_management
.
get_free_memory
(
q
.
device
)
mem_active
=
stats
[
'active_bytes.all.current'
]
mem_reserved
=
stats
[
'reserved_bytes.all.current'
]
mem_free_cuda
,
_
=
torch
.
cuda
.
mem_get_info
(
torch
.
cuda
.
current_device
())
mem_free_torch
=
mem_reserved
-
mem_active
mem_free_total
=
mem_free_cuda
+
mem_free_torch
gb
=
1024
**
3
gb
=
1024
**
3
tensor_size
=
q
.
shape
[
0
]
*
q
.
shape
[
1
]
*
k
.
shape
[
2
]
*
q
.
element_size
()
tensor_size
=
q
.
shape
[
0
]
*
q
.
shape
[
1
]
*
k
.
shape
[
2
]
*
q
.
element_size
()
...
...
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