Skip to content

Commit

Permalink
Reduce memory usage for sd 3.5. (#2582)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare authored Oct 28, 2024
1 parent 498bc2c commit 139ff56
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions candle-examples/examples/stable-diffusion-3/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ fn main() -> Result<()> {
let (context, y) = triple.encode_text_to_embedding(prompt.as_str(), &device)?;
let (context_uncond, y_uncond) =
triple.encode_text_to_embedding(uncond_prompt.as_str(), &device)?;
// Drop the text model early to avoid using too much memory.
drop(triple);
let context = Tensor::cat(&[context, context_uncond], 0)?;
let y = Tensor::cat(&[y, y_uncond], 0)?;

Expand Down

0 comments on commit 139ff56

Please sign in to comment.