when and how the trainer or module move the data to gpu? #13713
-
Automatically move data to GPU is fine. Also don't know when to move and how to move to GPU? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When the batch is transferred to device What is transferred to device Also, if you need to manually transfer tensors to device, you can utilise |
Beta Was this translation helpful? Give feedback.
Hi @FutureWithoutEnding
When the batch is transferred to device
I think the pseudocode in the docs explains when a batch is transferred to each device very well:
https://pytorch-lightning.readthedocs.io/en/1.6.5/common/lightning_module.html#hooks
What is transferred to device
See the list of supported data structures in the documentation. If you have custom data structure, you need to override this hook in your
LightningModule
:https://pytorch-lightning.readthedocs.io/en/1.6.5/common/lightning_module.html#transfer-batch-to-device
Also, if you need to manually transfer tensors to device, you can utilise
self.device
so that your code stays hardware-agnostic.your_tensor.to(self.device)
:htt…