InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

Textual inversion VRAM requirements

Open lugia19 opened this issue 4 years ago • 8 comments

I'm trying to run textual inversion on a 3080 (10GB of VRAM) and CUDA runs out of memory. Is it simply too little VRAM? Is there any workaround?

lugia19 avatar Aug 30 '22 16:08 lugia19

Didn't it need nearly 20GB to run textual inversion?

smoke2007 avatar Aug 30 '22 17:08 smoke2007

Well that'd explain the issue lol, I just wanted to be sure it was due to not having enough VRAM.

lugia19 avatar Aug 30 '22 17:08 lugia19

You can be my guinea pig :D https://github.com/lstein/stable-diffusion/pull/217 git pr checkout 217

Give it a try, see if it improves your experience. You can also edit this file here on line 55 and change it back to 256 to reduce your memory requirements even more.

For me, at 512, this took my mem usage from 16gb down to 9gb.

https://github.com/lstein/stable-diffusion/pull/217/commits/dbd4be137f8457a2b23adbb45c8d99423d7f9e54?diff=unified&w=1

david-ford avatar Aug 30 '22 17:08 david-ford

I was unable to get it to work at 512, but it does work at 256. I'll play around with the branch for a while.

lugia19 avatar Aug 30 '22 18:08 lugia19

I was unable to get it to work at 512, but it does work at 256. I'll play around with the branch for a while.

It may be a safer bet for me to make this the low-end optimized with a note for people with more headroom. I believe the difference is, that it will downscale the image to 256 while training, then upscale it back to 512 for testing. This results in a lot of data loss, and a less accurate result at the end of it because there's not as much information to assimilate.

david-ford avatar Aug 30 '22 19:08 david-ford

Didn't it need nearly 20GB to run textual inversion?

Google Colab used around 12-14GB as I remember.

morganavr avatar Aug 30 '22 19:08 morganavr

I checked in some more changes on this, optimized for low-end systems. PR - https://github.com/lstein/stable-diffusion/pull/226 I also fixed merging embeddings by copy-pasting from textual inversion with minor tweaks for SD priority. Commands are the same as before, they just work now.

david-ford avatar Aug 30 '22 23:08 david-ford

I was unable to get it to work at 512, but it does work at 256. I'll play around with the branch for a while.

I was able to make textual inversion run at 512 on my RTX 3080 10GB by setting max_split_size_mb, 500 seems to work fine.

lugia19 avatar Sep 04 '22 01:09 lugia19