Repository: stable-diffusion-webui
Issue: [Bug]: OutOfMemoryError: CUDA out of memory.
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [24:18<00:00, 48.62s/it]
*** Error completing request5, 48.43s/it]
*** Arguments: ('task(y45gdzs5l75m2r7)', '3d isometric, blender render, soft colorful-hued colors, In a sand sculpture style, <lora:Sand-Sculpture-Style-SCG-000011:0.7>, a coke bottle as an explosion of flavor. Two tone lighting, colorful background', '(worst quality, low quality, thumbnail:1.4), signature, artist name, web address, cropped, jpeg artifacts, watermark, username, collage, grid', [], 30, 'DPM++ 3M SDE Karras', 1, 1, 5.5, 1200, 768, False, 0.7, 2, 'Latent', 0, 0, 0, 'Use same checkpoint', 'Use same sampler', '', '', [], <gradio.routes.Request object at 0x000001C6871006D0>, 0, False, '', 0.8, -1, False, -1, 0, 0, 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, False) {}
    Traceback (most recent call last):
      File "F:\stable-diffusion-webui\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "F:\stable-diffusion-webui\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "F:\stable-diffusion-webui\modules\txt2img.py", line 55, in txt2img
        processed = processing.process_images(p)
      File "F:\stable-diffusion-webui\modules\processing.py", line 732, in process_images
        res = process_images_inner(p)
      File "F:\stable-diffusion-webui\modules\processing.py", line 875, in process_images_inner
        x_samples_ddim = decode_latent_batch(p.sd_model, samples_ddim, target_device=devices.cpu, check_for_nans=True)
      File "F:\stable-diffusion-webui\modules\processing.py", line 594, in decode_latent_batch
        sample = decode_first_stage(model, batch[i:i + 1])[0]
      File "F:\stable-diffusion-webui\modules\sd_samplers_common.py", line 76, in decode_first_stage
        return samples_to_images_tensor(x, approx_index, model)
      File "F:\stable-diffusion-webui\modules\sd_samplers_common.py", line 58, in samples_to_images_tensor
        x_sample = model.decode_first_stage(sample.to(model.first_stage_model.dtype))
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\models\diffusion.py", line 121, in decode_first_stage
        out = self.first_stage_model.decode(z)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\models\autoencoder.py", line 315, in decode
        dec = self.decoder(z, **decoder_kwargs)
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\model.py", line 732, in forward
        h = self.up[i_level].upsample(h)
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\model.py", line 65, in forward
        x = torch.nn.functional.interpolate(x, scale_factor=2.0, mode="nearest")
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\functional.py", line 3931, in interpolate
        return torch._C._nn.upsample_nearest2d(input, output_size, scale_factors)
    torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 450.00 MiB (GPU 0; 8.00 GiB total capacity; 13.57 GiB already allocated; 0 bytes free; 14.18 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

---

### Steps to reproduce the problem

——

### What should have happened?

The image was on the verge of completion, when a memory error occurred, aborting the creation of the nearly finished image.

### Sysinfo

——

### What browsers do you use to access the UI ?

Microsoft Edge

### Console logs

```Shell
100%|██████████████████████████████████████████████████████████████████████████████████| 30/30 [24:18<00:00, 48.62s/it]
*** Error completing request5, 48.43s/it]
*** Arguments: ('task(y45gdzs5l75m2r7)', '3d isometric, blender render, soft colorful-hued colors, In a sand sculpture style, <lora:Sand-Sculpture-Style-SCG-000011:0.7>, a coke bottle as an explosion of flavor. Two tone lighting, colorful background', '(worst quality, low quality, thumbnail:1.4), signature, artist name, web address, cropped, jpeg artifacts, watermark, username, collage, grid', [], 30, 'DPM++ 3M SDE Karras', 1, 1, 5.5, 1200, 768, False, 0.7, 2, 'Latent', 0, 0, 0, 'Use same checkpoint', 'Use same sampler', '', '', [], <gradio.routes.Request object at 0x000001C6871006D0>, 0, False, '', 0.8, -1, False, -1, 0, 0, 0, False, False, 'positive', 'comma', 0, False, False, '', 1, '', [], 0, '', [], 0, '', [], True, False, False, False, 0, False) {}
    Traceback (most recent call last):
      File "F:\stable-diffusion-webui\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "F:\stable-diffusion-webui\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "F:\stable-diffusion-webui\modules\txt2img.py", line 55, in txt2img
        processed = processing.process_images(p)
      File "F:\stable-diffusion-webui\modules\processing.py", line 732, in process_images
        res = process_images_inner(p)
      File "F:\stable-diffusion-webui\modules\processing.py", line 875, in process_images_inner
        x_samples_ddim = decode_latent_batch(p.sd_model, samples_ddim, target_device=devices.cpu, check_for_nans=True)
      File "F:\stable-diffusion-webui\modules\processing.py", line 594, in decode_latent_batch
        sample = decode_first_stage(model, batch[i:i + 1])[0]
      File "F:\stable-diffusion-webui\modules\sd_samplers_common.py", line 76, in decode_first_stage
        return samples_to_images_tensor(x, approx_index, model)
      File "F:\stable-diffusion-webui\modules\sd_samplers_common.py", line 58, in samples_to_images_tensor
        x_sample = model.decode_first_stage(sample.to(model.first_stage_model.dtype))
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\models\diffusion.py", line 121, in decode_first_stage
        out = self.first_stage_model.decode(z)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\models\autoencoder.py", line 315, in decode
        dec = self.decoder(z, **decoder_kwargs)
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\model.py", line 732, in forward
        h = self.up[i_level].upsample(h)
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
        return forward_call(*args, **kwargs)
      File "F:\stable-diffusion-webui\repositories\generative-models\sgm\modules\diffusionmodules\model.py", line 65, in forward
        x = torch.nn.functional.interpolate(x, scale_factor=2.0, mode="nearest")
      File "F:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\functional.py", line 3931, in interpolate
        return torch._C._nn.upsample_nearest2d(input, output_size, scale_factors)
    torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 450.00 MiB (GPU 0; 8.00 GiB total capacity; 13.57 GiB already allocated; 0 bytes free; 14.18 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

---
```


### Additional information

——