Haoming02 / sd-webui-old-photo-restoration

An Extension for Automatic1111 Webui for Bringing Old Photo Back to Life
MIT License
108 stars 6 forks source link

OutOfMemoryError #18

Closed li-marigold closed 5 months ago

li-marigold commented 5 months ago

Automatic 1111 v.1.9.0

Running Stage 1: Overall restoration model weights loaded processing... using NL + Res... processing... Error completing request Arguments: ('task(ka0dwwune9959vj)', 0.0, <PIL.Image.Image image mode=RGBA size=1057x808 at 0x1DB9BFA6320>, None, '', '', True, False, 0.0, 4, 0.0, 512, 512, True, 'None', 'None', 0, True, 1, False, 1, 0, False, 0.5, 0.2, False, 0.9, 0.15, 0.5, False, False, 384, 768, 4096, 409600, 'Maximize area', 0.1, False, ['Horizontal'], False, ['Deepbooru'], True, 'Restoration First', True, True, False) {} Traceback (most recent call last): File "E:\Stable Diffusion and AI\stable-diffusion-webui\modules\call_queue.py", line 57, in f res = list(func(*args, kwargs)) File "E:\Stable Diffusion and AI\stable-diffusion-webui\modules\call_queue.py", line 36, in f res = func(*args, *kwargs) File "E:\Stable Diffusion and AI\stable-diffusion-webui\modules\postprocessing.py", line 131, in run_postprocessing_webui return run_postprocessing(args, kwargs) File "E:\Stable Diffusion and AI\stable-diffusion-webui\modules\postprocessing.py", line 71, in run_postprocessing scripts.scripts_postproc.run(initial_pp, args) File "E:\Stable Diffusion and AI\stable-diffusion-webui\modules\scripts_postprocessing.py", line 185, in run script.process_firstpass(pp, process_args) File "E:\Stable Diffusion and AI\stable-diffusion-webui\extensions\sd-webui-old-photo-restoration\scripts\bop.py", line 46, in process_firstpass pp.image = main(img, do_scratch, is_hr, do_face_res) File "E:\Stable Diffusion and AI\stable-diffusion-webui\extensions\sd-webui-old-photo-restoration\scripts\main_function.py", line 56, in main stage1_output = global_test( File "E:\Stable Diffusion and AI\stable-diffusion-webui\extensions\sd-webui-old-photo-restoration\Global\test.py", line 139, in global_test generated = model.inference(input_image, mask) File "E:\Stable Diffusion and AI\stable-diffusion-webui\extensions\sd-webui-old-photo-restoration\Global\models\mapping_model.py", line 443, in inference label_feat_map = self.mapping_net(label_feat.detach(), inst_data) File "E:\Stable Diffusion and AI\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "E:\Stable Diffusion and AI\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "E:\Stable Diffusion and AI\stable-diffusion-webui\extensions\sd-webui-old-photo-restoration\Global\models\NonLocal_feature_mapping_model.py", line 70, in forward x2 = self.NL(x1, mask) File "E:\Stable Diffusion and AI\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "E:\Stable Diffusion and AI\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, **kwargs) File "E:\Stable Diffusion and AI\stable-diffusion-webui\extensions\sd-webui-old-photo-restoration\Global\models\networks.py", line 481, in forward f_div_C = F.softmax(f, dim=2) File "E:\Stable Diffusion and AI\stable-diffusion-webui\venv\lib\site-packages\torch\nn\functional.py", line 1856, in softmax ret = input.softmax(dim) torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 10.39 GiB. GPU 0 has a total capacty of 3.00 GiB of which 0 bytes is free. Of the allocated memory 13.04 GiB is allocated by PyTorch, and 329.16 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

A: 13.04 GB, R: 13.37 GB, Sys: 3.0/3 GB (100.0%)

Any suggestions how to solve this?

Haoming02 commented 5 months ago

Hmm What GPU are you using? And how large of an image were you trying to process?

li-marigold commented 5 months ago

Hmm What GPU are you using? And how large of an image were you trying to process? image size is 300x700 or something like that, but other processes (img generation from promt and etc working just fine) i think the reason in newer torch version)) I've tried to downgrade to 1.8)) but extension stopped work at all) ( Please tell how to fix ) or upload older version of BOP) I guess, it was mistake to update to 1.9 version of SD) it's buggy for now( especially for the old gpu's like mine gtx 1060)

Haoming02 commented 5 months ago

For now, you can go into the folder and edit this line to: https://github.com/Haoming02/sd-webui-old-photo-restoration/blob/main/scripts/main_function.py#L25

GPU_ID = -1
li-marigold commented 5 months ago

For now, you can go into the folder and edit this line to: https://github.com/Haoming02/sd-webui-old-photo-restoration/blob/main/scripts/main_function.py#L25

GPU_ID = -1

yay! It's worked! Thanks!!!