manicman1999 / StyleGAN2-Tensorflow-2.0

StyleGAN 2 in Tensorflow 2.0
MIT License
486 stars 112 forks source link

Can you make this work with Tensorflow 2.4.1 and above with tf.distribute.MirroredStrategy() #17

Open thusinh1969 opened 3 years ago

thusinh1969 commented 3 years ago

I almost give up that it keep posing error after error running with tf.distribute.MirroredStrategy().

ValueError: in user code:

<ipython-input-43-fa18d8117b40>:554 train_step  *
    gradients_of_generator = gen_tape.gradient(gen_loss, self.GAN.GM.trainable_variables)
C:\Users\ThuSi\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\backprop.py:1064 gradient  **
    flat_sources = [_handle_or_self(x) for x in flat_sources]
C:\Users\ThuSi\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\backprop.py:1064 <listcomp>
    flat_sources = [_handle_or_self(x) for x in flat_sources]
C:\Users\ThuSi\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\backprop.py:729 _handle_or_self
    return x.handle
C:\Users\ThuSi\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\distribute\values.py:639 handle
    raise ValueError("`handle` is not available outside the replica context"

ValueError: `handle` is not available outside the replica context or a `tf.distribute.Strategy.update()` call.

Can you make this work with Tensorflow 2.4.1 and above with tf.distribute.MirroredStrategy()

Thanks, Steve

manicman1999 commented 3 years ago

Hi! I'm currently in the middle of updating this code to work with multi-GPU machines and adaptive discriminator augmentation; keep an eye out for that!

robbelouwet commented 3 years ago

Hi, where are you on this? Do you have some idea on when the MirroredStrategy() will work?