Thanks for your reply.
Is it possible that the convergence becomes slower even if some gradients becomes NaNs or infs ?
My model is just autoencoder consisting of convolution, maxpooling, maxunpooling, relu, and sigmoid.
Anyway, to compare the gradients, I found that the gradients can be saved in a flatted form by
torch.cat([g.grad.view(-1) for g in model.parameters()],0)