Body
Testing Job Efficiency on HPC Systems
HPC Clusters operate differently from single node servers. Both will be covered below, keeping in mind that there will be overlap in some areas as they share the same tools.
Investigating Job Efficiency Via the Command Line
So you submitted your first job on the cluster using Slurm sbatch, congratulations! Now you can check, in real time, how efficient your resource calls are. Nodes are simply the servers that your job is running on. Think of an HPC cluster as a large conglomeration of server, attached via high speed networks to do your bidding. The simplest way to get real time monitoring is outlined below. If your job has already completed, you can skip to the next section called Using seff
to Check Job Efficiency After Job Completion (HPC Clusters).
Step 1: Accessing Nodes viaSSH
Determining the Node(s) your Job is using: Here you can invoke the squeue command, or better yet, filter squeue by your username.
[userl@cllogin002]$ squeue -u $USER
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
3197426 compute edge_exa user R 0:16 1 node003
Here you can see, under the NODELIST, that this job is running on node003.
Accessing a Node: Now that you know your node(s) that your job is running on, you can use the following command to ssh
into a node (note, you may get a warning, this is ok):
[user@cllogin002]$ ssh node003
Warning: Permanently added 'node003' (ED25519) to the list of known hosts.
[user@node003 ~]$
This puts you on the specific node allowing you to continue on to the next step. If you get an error, please contact us at sdsu.hpc@sdstate.edu and we can assist.
Step 2: Open top
to Monitor Resource Usage (Also used on Single Node Servers (i.e. Dune and Fennec)
Running top
: Once logged into the node, type the following command to launch the top
command:
[user@node003 ~]$ top
When you submitted your job via sbatch on the command line, you should have done so with a slurm script with resource requests, something akin to the following:
#SBATCH --ntasks=1 #Specifies the maximum amount of tasks that can be executed in parallel
#SBATCH --cpus-per-task=24 #Used to run the multithreaded task using X CPU-cores
#SBATCH --mem=500G #Defines the amount of memory you need for your job to run (Required)
If we use this for the example, I can look back at what top
was reporting and determine if I made the right resource request.
- This job requested 1 task and I am indeed only running one task.
- This job requested 24 cores, but we can see that I am only efficiently using 6 cores.
- This job requested 500GiB of memory yet it is only using half of that.
With this information, I can update my job script to better utilize resources on the cluster with something like the following:
#SBATCH --ntasks=1 #Specifies the maximum amount of tasks that can be executed in parallel
#SBATCH --cpus-per-task=6 #Used to run the multithreaded task using X CPU-cores
#SBATCH --mem=130G #Defines the amount of memory you need for your job to run (Required)
Using seff
to Check Job Efficiency After Job Completion (HPC Clusters)
Built into Slurm, is a tool that can be used to check efficiency only after the job has been completed. You will need your job ID and will need to run this in a timely fashion as records are not kept indefinitely. The seff
command will output key efficiency metrics, such as: Job Efficiency which is the percentage of allocated resources (CPU, memory, etc.) that were effectively used by the job, Elapsed Time: The total runtime of the job, Requested vs. Allocated Resources showing how much CPU or memory you requested versus what was allocated to your job, and Memory Utilization showing how much of the allocated memory was actually used.
When you submit your job, you will be given a job ID number, in this example, the job ID is 3198769 (*Note, your job ID will be different):
[user@cllogin002]$ sbatch yourjob.sbatch
Submitted batch job 3198769
#My slurm resource request:
#SBATCH --ntasks=1 #Specifies the maximum amount of tasks that can be executed in parallel
#SBATCH --cpus-per-task=24 #Used to run the multithreaded task using X CPU-cores
#SBATCH --time=0-00:15:00 #Time requested for your job to run. Format days-hours:minutes:seconds
#SBATCH --mem=500M #Defines the amount of memory you need for your job to run (Required)
Usingseff
after job id 3198769 ran, you will see output similar to the following:
[user@cllogin002]$ seff 3198769
Job ID: 3198769
Cluster: slurm
User/Group: /domain users
State: COMPLETED (exit code 0)
Nodes: 1
Cores per node: 24
CPU Utilized: 00:03:54
CPU Efficiency: 7.74% of 00:50:24 core-walltime
Job Wall-clock time: 00:02:06
Memory Utilized: 4.94 GB
Memory Efficiency: 1010.73% of 500.00 MB
We really only need to focus on the information after the completed state. With this information, we can see that my example job could be refined in terms of resources.
- State: COMPLETED (exit code 0) - The job ran without any errors, which is always nice.
- Nodes: 1, Cores per node: 24 - My job used 1 node and was allocated 24 CPU cores on that node.
- CPU Utilized: 00:03:54, CPU Efficiency: 7.74% of 00:50:24 core-walltime - I requested 24 CPU cores but only used about 7.74% of that. That’s a sign I asked for more CPU than I needed and I should adjust my resource request.
- Job Wall-clock time: 00:02:06 - My job only ran for a little over 2 minutes yet I requested 15 minutes.
- Memory Utilized: 4.94 GB, Memory Efficiency: 1010.73% of 500.00 MB - My job used 4.94 GB of RAM, even though you only requested 500 MB. I under-requested memory, but the system let it slide because spare memory was available to use. I need to adjust my sbatch script to avoid potential job failure on full systems.
In summary, my job finished fine, but it used a lot more memory than requested and only a little bit of the CPU resources. This will help me rewrite my resource request to something like the following:
#SBATCH --ntasks=1 #No Changes
#SBATCH --cpus-per-task=2 #Updated to 2 cores based on 8% of the 24 cores I requested
#SBATCH --time=0-00:05:00 #Updated per Job Wall-clock time as I don't need 15 minutes
#SBATCH --mem=5G #Updated to 5GB per Memory Utilization
With these changes, I can make better use of the resources provided by SDSU RCI.