Stylegan2 Training NaN for gp and loss_critic resulting to black pictures

I’ve recreated a code from a guide and follow every step and when the time that I try to train the model with my own pictures which are in 128x128 the resulting process for the gp and loss_critic results to a NaN. So I am guessing there might be some problems in my data or the equations inside the code. Asking for more insights on this problem. Below are the lines from gp and loss_critic

gp = gradient_penalty(critic, real, fake, device=DEVICE)
loss_critic = -(torch.mean(critic_real) - torch.mean(critic_fake)) + LAMBDA_GP * gp + (0.001 * torch.mean(critic_real ** 2))

and below is the guide that I am following. Thank you in advance.
https://blog.paperspace.com/implementation-stylegan2-from-scratch/#load-all-dependencies-we-need