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

Error when trying to restorate a picture #21

Closed Shogun1978 closed 4 months ago

Shogun1978 commented 4 months ago

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.

Haoming02 commented 4 months ago

Hmm.

What resolution was the image you tried to process?

Shogun1978 commented 4 months ago

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?

Haoming02 commented 4 months ago

Since you have:

OutOfMemoryError: CUDA out of memory

in the logs, I'd assume so

Haoming02 commented 4 months ago

How much System RAM do you have?

Shogun1978 commented 4 months ago

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.

Haoming02 commented 4 months ago

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.

Shogun1978 commented 4 months ago

Great! Thank you!