1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| export CUDA_VISIBLE_DEVICES=$1
all_cuda_devices=($(echo $CUDA_VISIBLE_DEVICES | sed 's/,/ /g'))
if (($# > 1));then tasks=$2;else tasks='qnli qqp mnli sst2' ;fi
task_nums=$(echo $tasks | awk -F ' ' '{print NF}')
if ((${#all_cuda_devices[*]} < $task_nums));then echo 显卡比任务少 exit 1 fi
now_use=0 for task_name in $tasks do export CUDA_VISIBLE_DEVICES=${all_cuda_devices[${now_use}]} now_use=$((${now_use}+1))
python -u train.py $task_name ..... 2>&1 > $task_name.log & echo start $task_name on GPU: $CUDA_VISIBLE_DEVICES done
|
执行: 1
| bash run.sh 0,1,2,3 ....
|