Skip to content

Fix GPU memory allocation issues #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nunchaku/models/transformers/transformer_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def forward_layer_at(
encoder_hidden_states = encoder_hidden_states.to(original_dtype).to(original_device)

return encoder_hidden_states, hidden_states

def __del__(self):
self.m.reset()

## copied from diffusers 0.30.3
def rope(pos: torch.Tensor, dim: int, theta: int) -> torch.Tensor:
Expand Down
3 changes: 2 additions & 1 deletion nunchaku/models/transformers/transformer_sana.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def forward_layer_at(
.to(original_dtype)
.to(original_device)
)

def __del__(self):
self.m.reset()

class NunchakuSanaTransformer2DModel(SanaTransformer2DModel, NunchakuModelLoaderMixin):
@classmethod
Expand Down