Skip to content

Instantly share code, notes, and snippets.

@Hayoung93
Hayoung93 / test_ddp.py
Created May 14, 2025 06:02
Test if DDP works fine
import torch
import torch.distributed as dist
import torch.nn as nn
import torch.optim as optim
import torch.multiprocessing as mp
from torch.nn.parallel import DistributedDataParallel as DDP
import os
import argparse
import datetime
@Hayoung93
Hayoung93 / run_clip.py
Created August 8, 2023 05:58
Extract image tag using CLIP
import torch
import clip
import argparse
from PIL import Image
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--model_name", type=str, choices=['RN50', 'RN101', 'RN50x4', 'RN50x16', 'RN50x64', 'ViT-B/32', 'ViT-B/16', 'ViT-L/14', 'ViT-L/14@336px'])
parser.add_argument("--image_fp", type=str)
@Hayoung93
Hayoung93 / ddp_example.py
Created August 1, 2023 02:15 — forked from sgraaf/ddp_example.py
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