Repository: stable-diffusion-webui
Issue: [Bug]: Computer crashes when inpainting large image
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?

Linux computer freezes when inpainting a large image. I noticed that the larger the image OR the larger the area to be inpainted is, the more likely for the freeze to happen.

I tried disabling *all* extensions, disabled tc_malloc, disabled xformers, but same thing happens, this is the last line of the console, showing it does not even start:
```
  0%|          | 0/16 [00:00<?, ?it/s] [00:29<00:00,  1.91s/it]
```

I tried "Inpaint area: Only masked" and it works longer, but with "Only masked padding, pixels: 256" it still happens.

I tried enabling and using "ControlNet v1.1.410" in the Inpaint tab, but it still happens.

### Steps to reproduce the problem

- add an image to Inpaint, 
-  write a short prompt, 
- mark a single area to be inpainted, 
- click Generate, then the computer freezes.



### What should have happened?

Image should have been generated.

### Sysinfo

[sysinfo.txt](https://github.com/AUTOMATIC1111/stable-diffusion-webui/files/12785620/sysinfo.txt)


### What browsers do you use to access the UI ?

Mozilla Firefox

### Console logs

```Log
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on woaiseeit user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
Python 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Checking ReActor requirements... Ok
Launching Web UI with arguments: --xformers
Civitai Helper: Get Custom Model Folder
[-] ADetailer initialized. version: 23.9.3, num models: 9
2023-10-02 21:10:51,210 - ControlNet - INFO - ControlNet v1.1.410
ControlNet preprocessor location: /home/woaiseeit/Projects/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads
2023-10-02 21:10:51,277 - ControlNet - INFO - ControlNet v1.1.410
21:10:51 - ReActor - STATUS - Running v0.4.2-b3
Loading weights [ca2412816b] from /home/woaiseeit/Projects/stable-diffusion-webui/models/Stable-diffusion/realistic/aZovyaPhotoreal_v2InpaintVAE.safetensors
Civitai Helper: Settings:
Civitai Helper: max_size_preview: True
Civitai Helper: skip_nsfw_preview: False
Civitai Helper: open_url_with_js: True
Civitai Helper: proxy: 
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 10.3s (prepare environment: 2.7s, import torch: 2.7s, import gradio: 0.7s, setup paths: 0.9s, initialize shared: 0.1s, other imports: 0.6s, load scripts: 1.6s, create ui: 0.7s, gradio launch: 0.2s).
Creating model from config: /home/woaiseeit/Projects/stable-diffusion-webui/configs/v1-inpainting-inference.yaml
Applying attention optimization: xformers... done.
Model loaded in 3.9s (load weights from disk: 1.0s, create model: 0.3s, apply weights to model: 2.3s, calculate empty prompt: 0.1s).





  6%|▋         | 1/16 [00:00<00:12,  1.21it/s]
Total progress:   0%|          | 0/16 [00:00<?, ?it/s]
```



### Additional information

`nvtop` output
![Screenshot from 2023-10-02 21-21-33](https://github.com/AUTOMATIC1111/stable-diffusion-webui/assets/134592603/ea2b9b5a-2b0e-4bc3-ab5d-eca933523bab)

To workaround it, one needs to send smaller images to the img2img generator, like this:
- Inpaint area: Only masked
- Only masked padding, pixels: >100, to give context to the generator
- Resize to: 512x512, or 512x768 etc depending on the rough shape of the masked content. What's essential is that **this size applies only to the generated content**, which is then integrated into the original image to produce the final result.