Hi I am learning the best ways to manage batches and other best practices during model training and inference and I have some:


If I have a batch that I move to GPU, should. I move it back to CPU after doing training? if no why?
batch, label = batch.to(device), label.to(device)
model(batch)
..Training pass... 
batch, label = batch.cpu(), label.cpu()

If I cache my data in my Dataset class how can I ensure I can reuse the same batches on gpu to avoid transferring from and to cpu multiple times?


Is to a best practice to calculate all performance metrics with detached tensors to avoid storing other graph nodes in memory?


Thanks in advance for any possible help.