Concept

Object-Oriented Trainer Device Support

To support GPU training in an object-oriented framework, a Trainer class must be configured to automatically manage device placement for both the data and the model. This is typically implemented by storing the target GPU devices during initialization, overriding a prepare_batch method to transfer incoming data minibatches to the target GPU, and overriding a prepare_model method to move the neural network's parameters to the exact same GPU before training begins.

0

1

Updated 2026-05-09

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L