BaşlayınÜcretsiz Başlayın

Automatic device placement with Accelerator

Your conversational AI model needs to train on a massive dataset, so you've decided to move the model to a GPU. You're leveraging Accelerator for automatic device placement. Note this exercise actually runs on the CPU, but the code remains the same for running on the GPU.

A BERT-based model has been preloaded as model.

Bu egzersiz

Efficient AI Model Training with PyTorch

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Declare an accelerator object by instantiating the appropriate class.
  • Use the accelerator object to prepare the model for distributed training with GPU.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from accelerate import Accelerator

# Declare an accelerator object
accelerator = ____()

# Prepare the model for distributed training
model = accelerator.____(model)

print(accelerator.device)
Kodu Düzenle ve Çalıştır