mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
567 stars 152 forks source link

VRAM of 8GB - Memory issues - anyone has a suggestion? #261

Closed miraculix95 closed 3 months ago

miraculix95 commented 6 months ago

If I play too much around with FaceSwaps, Loras, different checkpoints and refiners I regularly get memory errors and the API request fails. This looks like this:

Mar 25 12:15:11 pst9hxxwlbdr python3[8289]: ERROR diffusion_model.output_blocks.1.1.transformer_blocks.1.ff.net.0.proj.weight CUDA out of memory. Tried to allocate 50.00 MiB. GPU 0 has a total capacty of 7.79 GiB of which 44.50 MiB is free. Including non-PyTorch memory, this process has 7.74 GiB memory in use. Of the allocated memory 7.24 GiB is allocated by PyTorch, and 382.24 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

Now, the strange thing. If this happens, I even get into trouble to continue with a simple prompt without loras, refiners, ... Even restarting Fooocus-API does not help.

Using Fooocus 2.3. Has anyone an idea what I can do?

zeason commented 5 months ago

Is this happening when only using Fooocus itself?

mrhan1993 commented 5 months ago

try these paremeters when startup --always-low-vram --always-offload-from-vram

Mutai-Gilbert commented 5 months ago

I experienced the same issue on my Windows and MacBook devices, but worked when I moved to paperspace using A100-80G machine. Worked perfectly.