stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

CLIP interrogation leaks memory if the proccess fails

Open FerrahWolfeh opened this issue 3 years ago • 3 comments

Describe the bug When you use CLIP in img2img to generate a prompt, in case the GPU doesn't have enough memory and CLIP crashes with a "not enough VRAM" error, the memory used by CLIP stays allocated, while if the interrogation proccess succeeds, it frees memory as it shoud.

To Reproduce Steps to reproduce the behavior:

  1. Have a GPU with 6GB vram
  2. in img2img upload a big image (eg. 1920x1080)
  3. Use CLIP to interrogate the image and it should fail with OOM.

Expected behavior Wheter the proccess fails or not, the memory used to store the CLIP model, etc. shold be freed at the end of CLIP execution or dropped as soon as possible

Desktop (please complete the following information):

  • OS: Arch Linux | linux-zen 5.19.13
  • Browser Firefox
  • Commit revision dce7fc902ae2c6d9ffa71db67471abdcda72f82c

Additional context This is also somewhat related to issue #2180 since its pratically the same base issue (torch not dropping unused memory)

FerrahWolfeh avatar Oct 11 '22 12:10 FerrahWolfeh

Looking at the 'references timeline' on https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3449 also pointed me to this PR by @jn-jairo that was merged ~9 days ago:

  • https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4098
  • https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4142

@GeorgiaM-honestly I wonder if that's why you can't replicate the issues here anymore?

@RandomLegend have you updated to a version of the code that has that fix merged, and if so, are you still seeing issues despite it?

Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2180#issuecomment-1309434215


@FerrahWolfeh If you update to the latest code that includes those fixes above, is this still an issue?

0xdevalias avatar Nov 10 '22 00:11 0xdevalias

@0xdevalias when i observed and reported this issue i was on the latest code, yes.

However i just completely wiped the installation, with the venv and the repos and reinstalled from scratch. That fixed it. I assume it was some incompatibility with some old stuff laying around that wasn't cleared in recent commits.

RandomLegend avatar Nov 10 '22 00:11 RandomLegend

when i observed and reported this issue i was on the latest code, yes.

Yup, though given the fix I was talking about was only merged ~9 days ago and this issue has been open for a month that wouldn't have mattered.

However i just completely wiped the installation, with the venv and the repos and reinstalled from scratch. That fixed it.

Awesome! Glad to hear it :)

0xdevalias avatar Nov 10 '22 05:11 0xdevalias