Skip to content

Instantly share code, notes, and snippets.

View mrgomdev's full-sized avatar

Gimun Lee mrgomdev

  • Seoul, Republic of Korea
  • 07:44 (UTC +09:00)
View GitHub Profile
#!/bin/bash
# Check if a file path is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path_to_json_file>"
exit 1
fi
jsonFilePath=$1
@mrgomdev
mrgomdev / $Training_dreambooth.md
Last active January 25, 2023 15:22
Train dreambooth example, deepspeed ZeRO Stage 2, CPU Offload, 64GB RAM, rtx 3060 (VRAM 12GB)

Train dreambooth example

deepspeed ZeRO Stage 2, CPU Offload, 64GB RAM, rtx 3060 (VRAM 12GB)

Usage

conda create -n dreambooth python=3.8
conda activate dreambooth
pip install -r ./requirements.txt
accelerate config # Choose use deepspeed 'yes', zero stage '2', zero.Init() 'yes', offload all on 'cpu'
python -m accelerate.commands.launch --mixed_precision fp16 --config_file accelerate_config.yaml --deepspeed_config_file ds_config.json train_dreambooth.py
#!/bin/bash
sudo swapoff -a
sudo fallocate -l 16G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls /
ll /
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
train_int_to_int_transformer.py
import numpy as np
SEED = 42
RNG = np.random.default_rng(SEED)
def sample_triplets(xs: np.ndarray, n: int, each_size: int = 3) -> np.ndarray:
xs = np.asarray(xs)
assert xs.ndim == 1
triplets = set()