I am training multiple models in a sequential way on the same GPU, and I need them to share the parameters after a given number of iterations. For GPU sonsumption optimization I need to free the gradients of each model at the end of each optimizer iteration. A simple solution is to set all gradients to None manually, i.e.,
for param in model.parameters():
    param.grad = None

Is this is a good practice? If not what are the alternatives
Thanks in advance