[GH-ISSUE #21] Error when trying to restorate a picture #20

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

Originally created by @Shogun1978 on GitHub (May 10, 2024).
Original GitHub issue: https://github.com/Haoming02/sd-webui-old-photo-restoration/issues/21

Hello,
I just started with Stable Diffusion and wanted to restorate an old picture. After successful installation, I tried to run the restoration but got the following error:

OutOfMemoryError: CUDA out of memory. Tried to allocate 804.59 GiB. GPU 0 has a total capacty of 8.00 GiB of which 1.97 GiB is free. Process 1960 has 4.89 GiB memory in use. Of the allocated memory 3.97 GiB is allocated by PyTorch, and 814.40 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
Time taken: 1 min. 6.8 sec.

A: 6.24 GB, R: 6.26 GB, Sys: 7.5/8 GB (94.1%)

I am using a Tesla P4 with vGPU enabled. I tried with a 4GB VRAM and 8GB VRAM profile, but always get this error (when I run with 4GB of course with other/smaller values).

Am I doing something wrong? Normal processing works find inside Stable Diffusion.

Originally created by @Shogun1978 on GitHub (May 10, 2024). Original GitHub issue: https://github.com/Haoming02/sd-webui-old-photo-restoration/issues/21 Hello, I just started with Stable Diffusion and wanted to restorate an old picture. After successful installation, I tried to run the restoration but got the following error: OutOfMemoryError: CUDA out of memory. Tried to allocate 804.59 GiB. GPU 0 has a total capacty of 8.00 GiB of which 1.97 GiB is free. Process 1960 has 4.89 GiB memory in use. Of the allocated memory 3.97 GiB is allocated by PyTorch, and 814.40 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 Time taken: 1 min. 6.8 sec. A: 6.24 GB, R: 6.26 GB, Sys: 7.5/8 GB (94.1%) I am using a Tesla P4 with vGPU enabled. I tried with a 4GB VRAM and 8GB VRAM profile, but always get this error (when I run with 4GB of course with other/smaller values). Am I doing something wrong? Normal processing works find inside Stable Diffusion.
Author
Owner

@Haoming02 commented on GitHub (May 13, 2024):

Hmm.

What resolution was the image you tried to process?

<!-- gh-comment-id:2106545965 --> @Haoming02 commented on GitHub (May 13, 2024): Hmm. What resolution was the image you tried to process?
Author
Owner

@Shogun1978 commented on GitHub (May 13, 2024):

2259 x 3288 px (I've scanned an old picture with best possible resolution). And by asking me the right question, I might have found me issue: not enough memory to process such a large high-res picture. Am I right?

<!-- gh-comment-id:2106721860 --> @Shogun1978 commented on GitHub (May 13, 2024): 2259 x 3288 px (I've scanned an old picture with best possible resolution). And by asking me the right question, I might have found me issue: not enough memory to process such a large high-res picture. Am I right?
Author
Owner

@Haoming02 commented on GitHub (May 13, 2024):

Since you have:

OutOfMemoryError: CUDA out of memory

in the logs, I'd assume so

<!-- gh-comment-id:2106726420 --> @Haoming02 commented on GitHub (May 13, 2024): Since you have: > OutOfMemoryError: CUDA out of memory in the logs, I'd assume so
Author
Owner

@Haoming02 commented on GitHub (May 13, 2024):

How much System RAM do you have?

<!-- gh-comment-id:2106726889 --> @Haoming02 commented on GitHub (May 13, 2024): How much System RAM do you have?
Author
Owner

@Shogun1978 commented on GitHub (May 13, 2024):

The system memory of the VM is 4 or 8 GB, that is something I can easily set up to 64 GB. But the VRAM of the Tesla is just 8 GB. I think, this is the limitation. Unfortunately, I don't have access to a more powerful GPU yet. I will try to reduce the resolution of the picture and try again.

<!-- gh-comment-id:2106732730 --> @Shogun1978 commented on GitHub (May 13, 2024): The system memory of the VM is 4 or 8 GB, that is something I can easily set up to 64 GB. But the VRAM of the Tesla is just 8 GB. I think, this is the limitation. Unfortunately, I don't have access to a more powerful GPU yet. I will try to reduce the resolution of the picture and try again.
Author
Owner

@Haoming02 commented on GitHub (May 13, 2024):

Yeah, you can try lowering the input resolution first.

Alternatively, you can also try editing this line

https://github.com/Haoming02/sd-webui-old-photo-restoration/blob/main/scripts/main_function.py#L25

to:

GPU_ID = -1

to run it on the CPU instead.

<!-- gh-comment-id:2106735900 --> @Haoming02 commented on GitHub (May 13, 2024): Yeah, you can try lowering the input resolution first. Alternatively, you can also try editing this line > https://github.com/Haoming02/sd-webui-old-photo-restoration/blob/main/scripts/main_function.py#L25 to: ```py GPU_ID = -1 ``` to run it on the CPU instead.
Author
Owner

@Shogun1978 commented on GitHub (May 13, 2024):

Great! Thank you!

<!-- gh-comment-id:2106737383 --> @Shogun1978 commented on GitHub (May 13, 2024): Great! Thank you!
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#20
No description provided.