MulaiMulai sekarang secara gratis

Prepare datasets for distributed training

You've preprocessed a dataset for a precision agriculture system to help farmers monitor crop health. Now you'll load the data by creating a DataLoader and place the data on GPUs for distributed training, if GPUs are available. Note the exercise actually uses a CPU, but the code is the same for CPUs and GPUs.

Some data has been pre-loaded:

  • A sample dataset with agricultural imagery
  • The Accelerator class from the accelerate library
  • The DataLoader class

Latihan ini adalah bagian dari kursus

Efficient AI Model Training with PyTorch

Lihat Kursus

Petunjuk latihan

  • Create a dataloader for the pre-defined dataset.
  • Place the dataloader on available devices using the accelerator object.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

accelerator = Accelerator()

# Create a dataloader for the pre-defined dataset
dataloader = ____(____, batch_size=32, shuffle=True)

# Place the dataloader on available devices
dataloader = accelerator.____(____)

print(accelerator.device)
Edit dan Jalankan Kode