Fooocus icon indicating copy to clipboard operation
Fooocus copied to clipboard

[Bug]: ROCm Fooocus doesn't garbage collect allocated VRAM

Open infinity0 opened this issue 7 months ago • 13 comments

Checklist

  • [x] The issue has not been resolved by following the troubleshooting guide
  • [x] The issue exists on a clean installation of Fooocus
  • [x] The issue exists in the current version of Fooocus
  • [x] The issue has not been reported before recently
  • [ ] The issue has been reported before but has not been fixed yet

What happened?

On ROCm / amdgpu, Fooocus doesn't garbage collect used VRAM even after several hours. This means that other applications, such as other AI image generators, cannot use the VRAM and give "out of memory" errors.

Steps to reproduce the problem

  1. With ROCm with an AMD GPU, use Fooocus as normal - generate a few random pictures with default settings.
  2. Wait a few hours then run radeontop. See that VRAM allocation is still many GB.
  3. Use some other AI tool such as InvokeAI - generate a few random pictures with default settings.
  4. See that this other AI tool gives Out of VRAM errors.
  5. Close Fooocus and repeat (2, without waiting) and (3).
  6. VRAM allocation in radeontop is back down to normal levels. Also, the other AI tool succeeds.

What should have happened?

  1. Fooocus should release VRAM after it is finished generating images.

What browsers do you use to access Fooocus?

No response

Where are you running Fooocus?

Locally

What operating system are you using?

Debian GNU/Linux

Console logs

No relevant logs in Fooocus.

As described above, behaviour is observed empirically via other means, i.e.

1. `radeontop` VRAM usage before and after shutting down Fooocus
2. console logs of {other AI tool} before and after shutting down Fooocus.
   - before: OutOfMemoryError specifically VRAM
   - after: works fine

Additional information

No response

infinity0 avatar Jul 09 '24 11:07 infinity0