You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great repo, thanks for putting it together!
Question: I incorporated DiffusionKit to a FastApi API and it works great. However, I noticed that after generating an image, the memory used is not released. Given that Flux uses 26GB, it would be great if it would release all that memory. Is there a way to accomplish this? I tried to gc.collect, but that does not seem to do anything. You can see the code in my sample project.
Thanks!
Juan
The text was updated successfully, but these errors were encountered:
Hi @atiorh
Thanks for the quick reply. Using clear_cache did the trick. The memory gets released, which I great. In terms of memory usage, the terminal debug logging messages (when the pipeline verbose value is set to true) prints peak usage as 16 GB, but Activity monitor shows the python process using 26 GB.
I tried a basic image generation using the sample code from the readme (to rule out my other code from causing the high memory usage) and it still shows 26 GB in Activity monitor. See code at the bottom.
By the way, which version of Torch are you using? I downgraded to 2.3.0 since it kept complaining that "Torch version 2.4.1 has not been tested with coremltools. You may run into unexpected errors. Torch 2.3.0 is the most recent version that has been tested." Did not make a difference though, but I figured I'd ask just in case.
fromdiffusionkit.mlximportFluxPipelinepipeline=FluxPipeline(
shift=1.0,
model_version="argmaxinc/mlx-FLUX.1-schnell", # model_version="argmaxinc/mlx-FLUX.1-dev" for FLUX.1-devlow_memory_mode=True,
a16=True,
w16=True,
)
HEIGHT=512WIDTH=512NUM_STEPS=4# 4 for FLUX.1-schnell, 50 for SD3 and FLUX.1-devCFG_WEIGHT=0.# for FLUX.1-schnell, 5. for SD3image, _=pipeline.generate_image(
"a photo of a cat",
cfg_weight=CFG_WEIGHT,
num_steps=NUM_STEPS,
latent_size=(HEIGHT//8, WIDTH//8),
)
image.save("image.png")
Great repo, thanks for putting it together!
Question: I incorporated DiffusionKit to a FastApi API and it works great. However, I noticed that after generating an image, the memory used is not released. Given that Flux uses 26GB, it would be great if it would release all that memory. Is there a way to accomplish this? I tried to gc.collect, but that does not seem to do anything. You can see the code in my sample project.
Thanks!
Juan
The text was updated successfully, but these errors were encountered: