Stable Diffusion CUDA Out of Memory Error

Share
Workaround available Windows, Linux (NVIDIA GPUs) Updated November 14, 2026Based on 4 user reportsHow we research

Quick answer

The GPU ran out of VRAM for the image size, batch or model you chose. Lowering resolution and batch size, or launching with --medvram or --lowvram, usually fixes it.

Most likely fix: Lower the memory load

How to fix it

Try these in order — the most common fix is first.

  1. 1. Lower the memory load

    1. Reduce width and height (generate at 512x512 or 768x768, then upscale)
    2. Set Batch size to 1 and use Batch count instead
    3. Disable or lower Hires fix scale
    Did this fix it?
  2. 2. Add low-VRAM launch flags

    1. Open webui-user.bat (Windows) or webui-user.sh in a text editor
    2. Set COMMANDLINE_ARGS=--medvram (use --lowvram for 4 GB cards or less)
    3. Save and restart the web UI
    Did this fix it?
  3. 3. Tune the allocator and free VRAM

    1. Close browsers with GPU acceleration, games and other AI tools
    2. Set the PYTORCH_CUDA_ALLOC_CONF environment variable as suggested in the error message
    3. If it still fails, use a smaller model (SD 1.5) or a cloud GPU
    Did this fix it?

Symptoms

Generation stops with 'torch.cuda.OutOfMemoryError: CUDA out of memory' (or 'Tried to allocate X MiB'), often at high resolution, during hires fix, upscaling or when loading SDXL.

Why it happens

  • Image resolution or batch size too large for the card's VRAM
  • SDXL or large models on a 4-6 GB GPU
  • Hires fix or upscaler multiplying the working resolution
  • Other programs (browser, games) holding VRAM

This guide also covers

  • stable diffusion cuda out of memory
  • stable diffusion out of memory error
  • automatic1111 cuda out of memory

Still not working?

If Stable Diffusion keeps failing, you're not alone. See every Stable Diffusion problem users report or the alternatives people switch to.

Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.

Talk to us
Fixed it? Share this guide

The same problem in other apps

All not loading, error messages & connection guides →

Other Stable Diffusion errors

All 10 Stable Diffusion errors and fixes →