Skip to content

Instantly share code, notes, and snippets.

@nosarthur
Last active March 14, 2024 01:04
Show Gist options
  • Save nosarthur/137b7f6c220be7f27464bd6a1dabf3bf to your computer and use it in GitHub Desktop.
Save nosarthur/137b7f6c220be7f27464bd6a1dabf3bf to your computer and use it in GitHub Desktop.
slurm related
## query my jobs
```
alias fsa='sshare -A users -a |rg -v 0.000000 |sort -k7nr | grep -E "dzhou|santra|lwang|bier|cwu|jacobson|$"'
alias pi='srun --partition=compute-16core-64gb-preemptible --job-name=interactive --nodes=1 --ntasks-per-node=1 --pty bash'
alias q='squeue -u $USER | tee >(tail -n +2 |lc)'
#alias qq='squeue -p gpu-t4-4x-ondemand -t pd |tee >(tail -n +2 |lc)'
alias qqq='squeue -p gpu-t4-4x-ondemand-high-pri -t pd |tee >(tail -n +2 |lc)'
alias qd='scancel `q | tail -n +2| fzf | ff 1`'
alias qa='sacct --format=User,JobID,Jobname,partition,state,time,start,end,elapsed,WorkDir,MaxRss,MaxVMSize,nnodes,ncpus,nodelist -j'
alias si='sinfo | rg -v driver |rg -v session|rg -v gpu-t4-4x-preemptible |rg -v gpu-t4-4x-ondemand-h'
export SQUEUE_FORMAT="%.10i %.50j %.10u %.10T %.10M %.11l %.6D %R"
```
awk '{ sum += $'$1' } END { if (NR > 0) print sum / NR }'
awk ${@:2} '{ s += $'$1' } END { print s }'
#!/bin/bash
wait_time=20
user=${2-$USER}
while true
do
got=$(squeue -u $user | grep $1)
n_running=$(echo "$got" |grep -c 'RUNNING')
n_bad=$(echo "$got" |grep -cv 'RUNNING')
[ -z "$got" ] && n_bad=0
status=${n_running}-${n_bad}
#echo $status
if [[ $status != $old_status ]]; then
echo $n_running running
echo $n_bad not running
echo '-----------------' `date +%R`
fi
[[ $status == '0-0' ]] && exit 0;
old_status=$status
sleep $wait_time
done
echo done
t=${2-running}
case $1 in
gpu) p=gpu-t4-4x-ondemand;;
gpuh) p=gpu-t4-4x-ondemand-high-pri;;
gpup) p=gpu-t4-4x-preemptible;;
cpu) p=compute-16core-64gb-ondemand;;
driver) p=driver-4core-standard;;
*) p=compute-16core-64gb-preemptible;;
esac
squeue -p $p -O UserName -t $t -h| sort | uniq -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment