[GH-ISSUE #18] OutOfMemoryError #16

Closed
opened 2026-10-30 21:27:42 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @li-marigold on GitHub (Apr 16, 2024).
Original GitHub issue: https://github.com/Haoming02/sd-webui-old-photo-restoration/issues/18

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?

Originally created by @li-marigold on GitHub (Apr 16, 2024). Original GitHub issue: https://github.com/Haoming02/sd-webui-old-photo-restoration/issues/18 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?
Author
Owner

@Haoming02 commented on GitHub (Apr 16, 2024):

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

<!-- gh-comment-id:2059229632 --> @Haoming02 commented on GitHub (Apr 16, 2024): Hmm What GPU are you using? And how large of an image were you trying to process?
Author
Owner

@li-marigold commented on GitHub (Apr 16, 2024):

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)

<!-- gh-comment-id:2059614308 --> @li-marigold commented on GitHub (Apr 16, 2024): > 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)
Author
Owner

@Haoming02 commented on GitHub (Apr 17, 2024):

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
<!-- gh-comment-id:2060112454 --> @Haoming02 commented on GitHub (Apr 17, 2024): 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 ```py GPU_ID = -1 ```
Author
Owner

@li-marigold commented on GitHub (Apr 17, 2024):

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!!!

<!-- gh-comment-id:2060607323 --> @li-marigold commented on GitHub (Apr 17, 2024): > 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 > > ```python > GPU_ID = -1 > ``` yay! It's worked! Thanks!!!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Haoming02/sd-webui-old-photo-restoration#16
No description provided.