Skip to content

Commit b4b760d

Browse files
Quash memory leak when compel invocation called (#3633)
This commit prevents each image generation from leaking ~160 MB of VRAM. Thanks to @damian0815 and @StAlKeR7779 for helping to sort this out.
2 parents 252c790 + 4d2c780 commit b4b760d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

invokeai/app/invocations/compel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pydantic import BaseModel, Field
33
from contextlib import ExitStack
44
import re
5+
import torch
56

67
from .baseinvocation import BaseInvocation, BaseInvocationOutput, InvocationContext, InvocationConfig
78
from .model import ClipField
@@ -56,6 +57,7 @@ class Config(InvocationConfig):
5657
},
5758
}
5859

60+
@torch.no_grad()
5961
def invoke(self, context: InvocationContext) -> CompelOutput:
6062

6163
tokenizer_info = context.services.model_manager.get_model(

0 commit comments

Comments
 (0)