ZPdesu / Barbershop

Barbershop: GAN-based Image Compositing using Segmentation Masks (SIGGRAPH Asia 2021)
https://zpdesu.github.io/Barbershop/
MIT License
1.35k stars 265 forks source link

Cuda out of memory #33

Open rongfeng-china opened 2 years ago

rongfeng-china commented 2 years ago

The first time it worked well on my computer, but the second time I got this error.

RuntimeError: CUDA out of memory. Tried to allocate 128.00 MiB (GPU 0; 2.95 GiB total capacity; 1.86 GiB already allocated; 112.31 MiB free; 1.88 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

I tried the solutions below, and still facing the same issue. Solution 1: add torch.cuda.empty_cache() at the beginning of main.py Solution 2: reduce batch_size to 1 in /models/face_parsing/modules)/functions.py

Anyone has an idea?

Hamza4040 commented 2 years ago

@rongfeng-china can you please tell me.. how to reduce batch_size ?