I am learning the best ways to manage batches and other best practices during model training and inference and I have the following question:
- If I have a batch that I move to GPU, should. I move it back to CPU after doing the training? If no, why?
If I cache my data in mybatch, label = batch.to(device), label.to(device) model(batch) # ..Training pass... batch, label = batch.cpu(), label.cpu()
Dataset
class how can I ensure I can reuse the same batches on GPU to avoid transferring from and to CPU multiple times?