Skip to content

Instantly share code, notes, and snippets.

View webcsm's full-sized avatar

Rodrigo Ferreira webcsm

  • Microsoft
  • Rio de Janeiro, Brazil
View GitHub Profile
@sgraaf
sgraaf / ddp_example.py
Last active November 7, 2024 05:39
PyTorch Distributed Data Parallel (DDP) example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
import torch
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
from torch.utils.data import DataLoader, Dataset
from torch.utils.data.distributed import DistributedSampler
from transformers import BertForMaskedLM