Command Line stable diffusion runs out of GPU memory but GUI version doesn't
I installed the GUI version of Stable Diffusion here. With it I was able to make 512 by 512 pixel images using my GeForce RTX 3070 GPU with 8 GB of memory:

However when I try to do the same thing with the command line interface, I run out of memory:
Input:
&gt;&gt; C:\SD\stable-diffusion-main&gt;python scripts/txt2img.py --prompt &quot;a close-up portrait of a cat by pablo picasso, vivid, abstract art, colorful, vibrant&quot; --plms --n_iter 3 --n_samples 1 --H 512 --W 512
Error:
RuntimeError: CUDA out of memory. Tried to allocate 1024.00 MiB (GPU 0; 8.00 GiB total capacity; 6.13 GiB already allocated; 0 bytes free; 6.73 GiB reserved in total by PyTorch) If reserved memory is &gt;&gt; allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
If I reduce the size of the image to 256 X 256, it gives a result, but obviously much lower quality.
So part 1 of my question is why do I run out of memory at 6.13 GiB when I have 8 GiB on the card, and part 2 is what does the GUI do differently to allow 512 by 512 output? Is there a setting I can change to reduce the load on the GPU?
Thanks a lot,
Alex

This might not be the only answer, but I solved it by using the optimized version here. If you already have the standard version installed, just copy the &quot;OptimizedSD&quot; folder into your existing folders, and then run the optimized txt2img script instead of the original:
&gt;&gt; python optimizedSD/optimized_txt2img.py --prompt &quot;a close-up portrait of a cat by pablo picasso, vivid, abstract art, colorful, vibrant&quot; --H 512 --W 512 --seed 27 --n_iter 2 --n_samples 10 --ddim_steps 50
It's quite slow on my computer, but produces 512 X 512 images!
Thanks,
Alex
