xiaowei-hu / CycleGAN-tensorflow

Tensorflow implementation for learning an image-to-image translation without input-output pairs. https://arxiv.org/pdf/1703.10593.pdf
716 stars 294 forks source link

I have tried training 1024x1024 model but got OOM. How do I approach this? #20

Closed yeswecan closed 6 years ago

yeswecan commented 6 years ago

Hello there! As stated in subject, I tried modifying some config settings to allow the higher resolution to compute on GTX 1080 Ti that I have, with no luck. This is what I tried:

config = tf.ConfigProto(allow_soft_placement=True) config.gpu_options.allocator_type = 'BFC' config.gpu_options.per_process_gpu_memory_fraction = 0.40

Unfortunately, the tensor gets smaller but I still get OOM. Is there anything else I can try?

Thanks a lot in advance!

xiaowei-hu commented 6 years ago

I think you can test these tips (may be useful):

  1. Using a more shallow CNN architecture. For example, changing 9 residual blocks to 6 blocks.
  2. Random cropping patches from 1024x1024 images and resizing them to 512x512 or 256x256 during training; Using 1024x1024 images only for testing.
yeswecan commented 6 years ago

Thanks a lot for answering @xhujoy! Can I please ask you how do I approach changing CNN architecture in this project?

I tried method #2 but there were too many artifacts in comparison with testing with 512x512.

xiaowei-hu commented 6 years ago

In Line https://github.com/xhujoy/CycleGAN-tensorflow/blob/master/module.py#L94, the function generator_resnet defines the CNN architecture of generator. So you can change the number of residual block in this function, See Line https://github.com/xhujoy/CycleGAN-tensorflow/blob/master/module.py#L119.

yeswecan commented 6 years ago

Thanks @xhujoy I tried doing that but still get OOM, even though BFC that has per_process_gpu_memory_fraction = 0.01. Is there anything else you think I can try?

xiaowei-hu commented 6 years ago

Sry, I have no more ideas about this problem.