Difference between revisions of "Useful Slurm Commands"
From Rizzo_Lab
BrockBoysan (talk | contribs) |
BrockBoysan (talk | contribs) |
||
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | |||
+ | ==Basic Slurm commands== | ||
+ | |||
+ | * squeue -u $(whoami) - displays your running jobs and their job ids | ||
+ | * sinfo -l -a | grep idle - displays available nodes (note: some nodes may have exclusive access to certain lab groups) | ||
+ | * scancel <jobid> - remove the job from the queue | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Advanced Tricks== | ||
+ | Delete all your jobs (use with caution) | ||
+ | scancel -u $(whoami) | ||
+ | |||
+ | Delete all your queued jobs only. Leaves all runnings jobs alone. | ||
+ | scancel -u $(whoami) -t "PENDING" | ||
+ | |||
+ | |||
==Sample slurm script for many independent jobs== | ==Sample slurm script for many independent jobs== | ||
#!/bin/bash | #!/bin/bash | ||
− | #SBATCH --time= | + | #SBATCH --time=2-00:00:00 #lower times get higher priority in the queuing system |
− | #SBATCH --nodes=3 | + | #SBATCH --nodes=3 #number |
#SBATCH --ntasks=(# cores per node) * (# nodes) #this should equal the number of jobs you want to run at the same time | #SBATCH --ntasks=(# cores per node) * (# nodes) #this should equal the number of jobs you want to run at the same time | ||
#SBATCH --job-name=<your_job_name> | #SBATCH --job-name=<your_job_name> | ||
Line 11: | Line 31: | ||
JOB_FILE="<your common input file>" | JOB_FILE="<your common input file>" | ||
CDIR=$(pwd) | CDIR=$(pwd) | ||
− | # Assuming your paths to experiments are listed line by line in a file named paths.txt | + | # Assuming your paths to experiments are listed line by line in a file named paths.txt, which should have # paths = # cores = # tasks |
while IFS= read -r path; do | while IFS= read -r path; do | ||
cp $JOB_FILE -t $path | cp $JOB_FILE -t $path | ||
Line 21: | Line 41: | ||
done < paths.txt | done < paths.txt | ||
wait #necessary to prevent the script from ending and terminating your jobs | wait #necessary to prevent the script from ending and terminating your jobs | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 15:38, 22 February 2024
Basic Slurm commands
- squeue -u $(whoami) - displays your running jobs and their job ids
- sinfo -l -a | grep idle - displays available nodes (note: some nodes may have exclusive access to certain lab groups)
- scancel <jobid> - remove the job from the queue
Advanced Tricks
Delete all your jobs (use with caution)
scancel -u $(whoami)
Delete all your queued jobs only. Leaves all runnings jobs alone.
scancel -u $(whoami) -t "PENDING"
Sample slurm script for many independent jobs
#!/bin/bash #SBATCH --time=2-00:00:00 #lower times get higher priority in the queuing system #SBATCH --nodes=3 #number #SBATCH --ntasks=(# cores per node) * (# nodes) #this should equal the number of jobs you want to run at the same time #SBATCH --job-name=<your_job_name> #SBATCH --output=<std_out_filename> #SBATCH -p <partition_name> DOCK_PATH="<path to dock bin/executable>" JOB_FILE="<your common input file>" CDIR=$(pwd) # Assuming your paths to experiments are listed line by line in a file named paths.txt, which should have # paths = # cores = # tasks while IFS= read -r path; do cp $JOB_FILE -t $path cd $path base=$(basename -s .in $JOB_FILE) # You can modify this srun command based on your requirements, the -n1 requests 1 core for the srun job, the -N1 requests 1 node, the --exclusive prevents this job's cores from being used in other jobs, -W 0 tells the script to not give the job a timelimit srun --mem=6090 --exclusive -N1 -n1 -W 0 $DOCK_PATH/dock6.rdkit -i $base.in -o $base.out & cd $CDIR done < paths.txt wait #necessary to prevent the script from ending and terminating your jobs