Difference between revisions of "Rocky Slurm Basic Multi"
From NIMBioS
(→About) |
|||
Line 1: | Line 1: | ||
__TOC__ | |||
= About = | = About = | ||
Line 15: | Line 17: | ||
For example purposes, we'll use a simple bash script. It's only purpose is to output the hostname of the node we're on and the cpuid the script is running. This will help illustrate that our script is being run on multiple nodes and/or multiple cores on each node. | For example purposes, we'll use a simple bash script. It's only purpose is to output the hostname of the node we're on and the cpuid the script is running. This will help illustrate that our script is being run on multiple nodes and/or multiple cores on each node. | ||
= Multiple Nodes = | |||
'''slurm-test-nodes.sh''' | |||
<pre> | |||
#!/bin/bash | |||
#SBATCH --job-name=test_nodes_job | |||
#SBATCH --nodes=3 | |||
#SBATCH --output=test_nodes_%j.log | |||
srun myscript.sh | |||
</pre> | |||
Here you can see we are telling sbatch to use 3 nodes for this job. | |||
<pre> | |||
sbatch slurm-test-nodes.sh | |||
</pre> | |||
'''test_nodes_2954.log''' | |||
<pre> | |||
moose1 (20) | |||
moose2 (20) | |||
rocky1 (40) | |||
</pre> | |||
Here you can see from the output that the job used 3 nodes (moose1, moose2, and rocky1). |
Revision as of 20:56, 25 August 2022
About
In these examples, you'll see how to use SBATCH parameters to take advantage of multiple nodes and multiple cores on those nodes.
myscript.sh
#!/bin/bash H=`hostname -s` C=`ps -o cpuid -h -p ${BASHPID} | xargs` echo "${H} (${C})"
For example purposes, we'll use a simple bash script. It's only purpose is to output the hostname of the node we're on and the cpuid the script is running. This will help illustrate that our script is being run on multiple nodes and/or multiple cores on each node.
Multiple Nodes
slurm-test-nodes.sh
#!/bin/bash #SBATCH --job-name=test_nodes_job #SBATCH --nodes=3 #SBATCH --output=test_nodes_%j.log srun myscript.sh
Here you can see we are telling sbatch to use 3 nodes for this job.
sbatch slurm-test-nodes.sh
test_nodes_2954.log
moose1 (20) moose2 (20) rocky1 (40)
Here you can see from the output that the job used 3 nodes (moose1, moose2, and rocky1).