经常使用 slurm 命令,今天索性总结并缩写一下:
sh
ask(){
local partition=$1
case "$partition" in
a)
srun -p A40 --gres=gpu:1 -c 20 --pty bash
;;
A)
srun -p A100 --gres=gpu:1 -c 20 --pty bash
;;
v)
srun -p V100-16GB --gres=gpu:1 -c 20 --pty bash
;;
V)
srun -p V100-32GB --gres=gpu:1 -c 20 --pty bash
;;
p)
srun -p P100 --gres=gpu:1 -c 20 --pty bash
;;
c)
srun -p CPU -c 20 --pty bash
;;
H)
srun -p H100 --gres=gpu:1 -c 20 --pty bash
;;
*)
srun -p $partition --gres=gpu:1 -c 20 --pty bash
;;
esac
}
job() {
if [ $# -eq 0 ]; then
# 无参数,查看节点信息
sinfo
else
case "$1" in
me|m)
squeue -u "$USER"
;;
all|a)
squeue
;;
''|*[!0-9]*)
echo "用法:job [me|all|<jobid>]"
;;
*)
# 如果参数全是数字,就当作 jobid
scontrol show job "$1"
;;
esac
fi
}