2024-03-29 06:12:29 +00:00
|
|
|
set_n_least_used_CUDA_VISIBLE_DEVICES() {
|
|
|
|
local n=${1:-"9999"}
|
|
|
|
echo "GPU Memory Usage:"
|
|
|
|
local FIRST_N_GPU_IDS=$(nvidia-smi --query-gpu=memory.used --format=csv |
|
|
|
|
tail -n +2 |
|
|
|
|
nl -v 0 |
|
|
|
|
tee /dev/tty |
|
|
|
|
sort -g -k 2 |
|
|
|
|
awk '{print $1}' |
|
|
|
|
head -n $n)
|
|
|
|
export CUDA_VISIBLE_DEVICES=$(echo $FIRST_N_GPU_IDS | sed 's/ /,/g')
|
|
|
|
echo "Now CUDA_VISIBLE_DEVICES is set to:"
|
|
|
|
echo "CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# export CUDA_VISIBLE_DEVICES=4,5,6
|
|
|
|
set_n_least_used_CUDA_VISIBLE_DEVICES 4
|
|
|
|
PROJECT_NAME="sft"
|
2024-05-27 05:55:57 +00:00
|
|
|
PARENT_SAVE_DIR="/home/yeanbang/data/experiment/output/model" # Path to a folder to save checkpoints
|
|
|
|
PARENT_TENSORBOARD_DIR="/home/yeanbang/data/experiment/logs/tensorboard" # Path to a folder to save logs
|
|
|
|
PARENT_CONFIG_FILE="/home/yeanbang/data/experiment/logs/config" # Path to a folder to save training config logs
|
|
|
|
PRETRAINED_MODEL_PATH="/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" # huggingface or local model path
|
|
|
|
PRETRAINED_TOKENIZER_PATH="/mnt/jfs-hdd/share/models/Llama-2-7b-chat-hf" # huggingface or local tokenizer path
|
2024-03-29 06:12:29 +00:00
|
|
|
declare -a dataset=(
|
2024-05-27 05:55:57 +00:00
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00000
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00001
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00002
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00003
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00004
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00005
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00006
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00007
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00008
|
|
|
|
/home/yeanbang/data/experiment/dataset/alpaca/test/Llama-2-7b-chat-hf/arrow/part-00009
|
2024-03-29 06:12:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)
|
|
|
|
FULL_PROJECT_NAME="${PROJECT_NAME}-${TIMESTAMP}"
|
|
|
|
SAVE_DIR="${PARENT_SAVE_DIR}${FULL_PROJECT_NAME}"
|
|
|
|
CONFIG_FILE="${PARENT_CONFIG_FILE}-${FULL_PROJECT_NAME}.json"
|
|
|
|
|
2024-05-27 05:55:57 +00:00
|
|
|
echo $(which colossalai)
|
|
|
|
echo $(which python)
|
2024-03-29 06:12:29 +00:00
|
|
|
# the real batch size for gradient descent is number_of_node_in_hostfile * nproc_per_node * train_batch_size
|
|
|
|
colossalai run --nproc_per_node 4 --master_port 31312 --hostfile ./hostfile train_sft.py \
|
|
|
|
--pretrain $PRETRAINED_MODEL_PATH \
|
|
|
|
--tokenizer_dir $PRETRAINED_TOKENIZER_PATH \
|
|
|
|
--save_interval 4000 \
|
|
|
|
--dataset ${dataset[@]} \
|
|
|
|
--save_path $SAVE_DIR \
|
|
|
|
--config_file $CONFIG_FILE \
|
|
|
|
--lora_rank 0 \
|
|
|
|
--plugin zero2 \
|
2024-05-27 05:55:57 +00:00
|
|
|
--tp 1 \
|
|
|
|
--pp 1 \
|
|
|
|
--zero_stage 2 \
|
|
|
|
--batch_size 4 \
|
|
|
|
--max_epochs 3 \
|
|
|
|
--accumulation_steps 4 \
|
|
|
|
--lr 5e-5 \
|
|
|
|
--max_len 400 \
|
2024-03-29 06:12:29 +00:00
|
|
|
--grad_checkpoint \
|
2024-05-27 05:55:57 +00:00
|
|
|
--use_wandb \
|
|
|
|
--use_flash_attn
|