Skip to content

Instantly share code, notes, and snippets.

View mtntruong's full-sized avatar
₍ᐢ. .ᐢ₎

Mai Thanh Nhat Truong mtntruong

₍ᐢ. .ᐢ₎
View GitHub Profile
@mtntruong
mtntruong / utils.sh
Last active October 31, 2025 04:47
Personal collection of utility bash scripts/commands
#---------------------------------------------------------
# Timimg
#---------------------------------------------------------
#!/bin/bash
start=$(date +%s.%N)
# HERE BE CODE
end=$(date +%s.%N)
runtime=$(python -c "print(${end} - ${start})")
@mtntruong
mtntruong / ddp_example.py
Created November 12, 2022 05:07 — 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