LLaMA-Factory-310P3/run_once.sh

52 lines
1.3 KiB
Bash
Raw Normal View History

2024-09-05 12:54:15 +08:00
#!/bin/bash
2024-09-05 12:59:02 +08:00
run_type="$1"
model="$2"
gpu_cnt="$3"
max_steps="$4"
2024-09-05 11:28:19 +08:00
current_datetime=$(date +%Y%m%d%H%M%S)
2024-09-05 12:59:02 +08:00
if [ "${run_type}"="lora_sft" ]; then
2024-09-05 11:28:19 +08:00
run_name="${run_type}_${model}_${gpu_cnt}_gpu_${max_steps}_step_${current_datetime}"
else
run_name="${run_type}_${model}_${gpu_cnt}_gpu_${current_datetime}"
fi
2024-09-05 12:59:52 +08:00
output_dir="./results/${run_name}"
2024-09-05 11:28:19 +08:00
if [ ! -d "$output_dir" ]; then
mkdir -p "$output_dir"
2024-09-05 13:09:43 +08:00
echo "output_dir created: $output_dir"
2024-09-05 11:28:19 +08:00
else
2024-09-05 13:09:43 +08:00
echo "output_dir exists: $output_dir"
2024-09-05 11:28:19 +08:00
fi
2024-09-05 13:09:43 +08:00
# echo "${run_type} ${model} ${gpu_cnt} ${max_steps} ${run_name} ${output_dir}"
python prepare_yaml_file.py ${run_type} ${model} ${max_steps} ${run_name} ${output_dir}
2024-09-05 11:28:19 +08:00
2024-09-05 13:37:17 +08:00
export USE_MODELSCOPE_HUB=1
2024-09-05 11:28:19 +08:00
2024-09-05 14:41:48 +08:00
# echo "Start recording gpu status "
# # 0 means not printing gpu status
# python gpu_status.py ${output_dir} 1 10 &
# gpu_status_pid=$!
# echo "${gpu_status_pid}"
if [ "${gpu_cnt}"="1" ]; then
2024-09-05 15:17:39 +08:00
ASCEND_RT_VISIBLE_DEVICES=0 llamafactory-cli train ${output_dir}/${run_name}.yaml | tee "${output_dir}/log.txt" &
2024-09-05 14:41:48 +08:00
train_pid=$!
echo "Start train"
else
2024-09-05 15:17:39 +08:00
FORCE_TORCHRUN=1 llamafactory-cli train ${output_dir}/${run_name}.yaml | tee "${output_dir}/log.txt" &
2024-09-05 14:41:48 +08:00
train_pid=$!
echo "Start train"
fi
wait $train_pid
echo "Train ended"
2024-09-05 13:37:17 +08:00
2024-09-05 14:41:48 +08:00
# sleep 90
# kill $gpu_status_pid
# echo "Gpu status ended"