To submit a batch task on the cluster, it requires a SLURM script to clarify the requested resources and the programs to run.
Check Available Resource
Before the submission, please check the compute nodes’ status to insure it/they has/have enough resource to run the upcoming jobs.
user_name@Control:~$ sinfoPARTITION AVAIL TIMELIMIT NODES STATE NODELISTCPU-Compute-1* up 1-00:00:00 1 idle Compute2030005000CPU-Compute-2 up 7-00:00:00 1 idle Compute2030005001GPU-Compute-1 up 7-00:00:00 1 mix Compute2030005002GPU-Compute-2 up infinite 1 alloc Compute2030005003
As the example shown, sinfo can roughly shows the information of all the partitions.
- If the STATE column is “idle”, it means the node is in an idle state
- If the STATE column is “alloc”, it means the node is full
- If the STATE column is “mix”, it means that the node is occupied by someone, but it still has remaining resources
You can also use the pestat to check the detail of each node:
user_name@Control:~$ pestat
Hostname Partition Node Num_CPU CPUload Memsize Freemem Joblist
State Use/Tot (MB) (MB) JobId User ...
Compute2030005000 CPU-Compute-1* idle 0 40 1.11* 128000 35643
Compute2030005001 CPU-Compute-2 idle 0 40 0.11 128000 34578
Compute2030005002 GPU-Compute-1 mix 2 40 16.30 128000 37085 1422 user_2
Compute2030005003 GPU-Compute-2 alloc 40 40 35.50* 128000 29748 1454 user_1
SLURM Script
A SLURM script is needed to complete the task submission. The SLURM script can be written locally and uploaded via sftp/ftp, or it can be edited directly on the cluster.
A SLURM script can include multiple content, the following template lists commonly used options:
<File Name: run.slurm>
#!/bin/bash
#SBATCH -J test # Task's name: test (optional)
#SBATCH -o test.out # Output File: test.out (optional)
#SBATCH -p CPU-Compute-1 # Partition CPU-Compute-1 (optional)
#SBATCH -N 1 # Request for 1 Node (optional)
#SBATCH --ntasks-per-node=1 # 1 task for 1 node (optional)
#SBATCH --cpus-per-task=4 # 4 CPU Cores for 1 task (optional)
#SBATCH -t 1:00:00 # time: 1 hour (optional)
#SBATCH --gres=gpu:tasla:no_resume:1 # Request 1 GPU (optional)
#SBATCh -w Compute2030005000 # Node Name: Compute2030005000 (optional)
# activate environment and load software
source ~/environment/anaconda-5.3.1 # load anaconda
source activate test # activate conda environment
python test.py # run python file: test.py
An exmaple of using MATLAB
#!/bin/bash
#SBATCH -J test
#SBATCH -o test.out
#SBATCH -p GPU-Compute
source /home/user_name/environment/MATLAB
$matlab -r 'file_name'
Change User_name to your Username; change file_name to your M file’s name without .m
You can use the Script-Generator to generate a SLURM script: Slurm-Script-Generator
Check Task’s Status
After the submission, you can use squeue to check the status of your task:
user_name@Control:~$ squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
1454 GPU-Compu test user_1 R 22-17:04:56 1 Compute2030005003
1422 GPU-Compu debug user_2 R 01:30 1 Compute2030005002
squeue -l: can show detailed informationsqueue -u user_name: only show user_name’s tasksqueue -t state: only shows the task with “state” status
To cancel task:
scancel jobid: cancel the task with JobID = jobidscancel -u user_name: cancel all the tasks belong to user_namescancel -s state: Delete all the tasks with “state” status
User can only cancel its only task, not others!
