Porting PyTorch Models to Gaudi
Porting PyTorch Models to Gaudi¶
This section details the steps required to prepare PyTorch models to run on Gaudi. To create and execute a simple PyTorch model with Gaudi, see Getting Started with PyTorch and Gaudi.
Import Habana Torch Library:
import habana_frameworks.torch.core as htcore
Target the Gaudi HPU device:
device = torch.device("hpu")
Add
mark_step()
. In Lazy mode,mark_step()
must be added in all training scripts right afterloss.backward()
andoptimizer.step()
.
htcore.mark_step()
Note
Placing
mark_step()
at any arbitrary point in the code is currently not supported.