开始使用免费开始使用

Prepare a model for distributed training

You've decided to use the Hugging Face Accelerator library to train your language translation model. Now it's time to prepare your model for distributed training!

Some data has been pre-loaded:

  • accelerator is an instance of Accelerator
  • model, optimizer, train_dataloader, and lr_scheduler have been defined

本练习是课程的一部分

Efficient AI Model Training with PyTorch

查看课程

练习说明

  • Call a method to prepare objects for distributed training.
  • Pass the training objects as positional arguments to accelerator.prepare(), matching the order of the output.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Prepare objects for distributed training
model, optimizer, train_dataloader, lr_scheduler = ____.____(
    # Pass in the training objects matching the order of the output
    ____,
    ____,
    ____,
    ____)
编辑并运行代码