Nan is not caused by gradient vanishing, more oftenly it is caused by updating a part of your model continuously using extremely large gradients, like something divided by zero. then Nan will ocurr in all parameters.
Try clipping your gradient using torch.nn.utils.clip_grad_norm_or debug your model gradients using module.register_backward_hook