2023-03-28 12:25:36 +00:00
|
|
|
set_n_least_used_CUDA_VISIBLE_DEVICES() {
|
|
|
|
local n=${1:-"9999"}
|
|
|
|
echo "GPU Memory Usage:"
|
2023-06-29 02:48:09 +00:00
|
|
|
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)
|
2023-03-28 12:25:36 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
|
|
|
set_n_least_used_CUDA_VISIBLE_DEVICES 2
|
|
|
|
|
2023-04-17 06:46:50 +00:00
|
|
|
# torchrun --standalone --nproc_per_node=2 train_prompts.py prompts.csv --strategy colossalai_zero2
|
|
|
|
|
2023-06-29 02:48:09 +00:00
|
|
|
torchrun --standalone --nproc_per_node=2 train_prompts.py \
|
|
|
|
--pretrain_dataset /path/to/data.json \
|
|
|
|
--prompt_dataset /path/to/data.json \
|
|
|
|
--strategy colossalai_zero2 \
|
|
|
|
--num_episodes 1 --num_collect_steps 2 --num_update_steps 1 \
|
|
|
|
--train_batch_size 2
|