gsurma / image_generator

DCGAN image generator 🖼️.
https://gsurma.github.io
MIT License
216 stars 82 forks source link

Out of memory #2

Closed baizhenmao95 closed 5 years ago

baizhenmao95 commented 5 years ago

Hi, thanks for your sharing. I want to try some my own pictures but I get the error "out of memory" every time. When I try it on my own PC, with NVIDIA GTX950 GPU, I got the ''out of memory'' in about 100 epochs. When I try it on the PC with NVIDIA GTX1080Ti GPU, I got the ''out of memory'' in about 700 epochs. I have no idea why it happens. Do you have any ideas? Thank you very much!

gsurma commented 5 years ago

Actually it's very simple - you are running out of memory.

I would suggest two things:

  1. Reduce number of persistent allocations like images generated after every epoch. Right now they are appended after every epoch so you can either generate them less often or just try to overwrite them instead of appending.

  2. Switch to an approach where you will storing image paths in RAM instead of images itself. It might be slower but it will use significantly less memory. You can check example there: https://github.com/gsurma/face_generator