huggingface / diffusers

🤗 Diffusers: State-of-the-art diffusion models for image and audio generation in PyTorch and FLAX.
https://huggingface.co/docs/diffusers
Apache License 2.0
25.35k stars 5.25k forks source link

how to unload a pipeline #8721

Closed nono909090 closed 2 months ago

nono909090 commented 3 months ago

how to unload a pipeline and release the gpu memory

asomoza commented 3 months ago

you don't have to do anything special, you can use None or del, just need to make sure you don't have reference to it or the models anywhere else.

If you don't see the memory freed, you can force it with this:

torch.cuda.empty_cache()
nono909090 commented 3 months ago

you don't have to do anything special, you can use None or del, just need to make sure you don't have reference to it or the models anywhere else.

If you don't see the memory freed, you can force it with this:

torch.cuda.empty_cache()

yes,it works! thank you

asomoza commented 2 months ago

glad it worked, closing this issue now then.