{"id":87,"date":"2020-09-20T03:38:51","date_gmt":"2020-09-20T03:38:51","guid":{"rendered":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/?page_id=87"},"modified":"2020-11-03T08:19:43","modified_gmt":"2020-11-03T08:19:43","slug":"how-to-create-a-slurm-file","status":"publish","type":"page","link":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/how-to-create-a-slurm-file\/","title":{"rendered":"How to create a SLURM file?"},"content":{"rendered":"\n<p>If you are new to the command-line interface (CLI) and do not know how to edit files in CLI, please refer to <a href=\"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/using-nano\/\" data-type=\"page\" data-id=\"212\">this page<\/a> for a tutorial of using the text editor <em>nano<\/em>. <\/p>\n\n\n\n<p>A SLURM file has two parts: 1) The <em>#SBATCH<\/em> directives and 2) the commands you want to execute within the job.<\/p>\n\n\n\n<p>Here is an example file named &#8220;<span style=\"color:#cf2e2e\" class=\"tadv-color\">example.slurm<\/span>&#8220;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#SBATCH --nodes=1\n#SBATCH --ntasks-per-node=4\n#SBATCH --mem-per-cpu=1G\n#SBATCH --time=01:00:00\n#SBATCH --partition=week-long-cpu\n#SBATCH --job-name=HelloWorld\n#SBATCH --error=job.%J.err\n#SBATCH --output=job.%J.out\n\necho \"HelloWorld\"\nsleep 300<\/code><\/pre>\n\n\n\n<p>The script above will request for 1 node, 4 cores, 4Gb memory (1G per core), 1 hour run time on the partition named &#8216;week-long-cpu&#8217;. The job name is &#8216;HelloWorld&#8217;. This job will print &#8216;HelloWorld&#8217; to the output file then stay idle for another 300 seconds. <\/p>\n\n\n\n<p>General SLURM directives:<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-cb58e514-828d-448d-8c95-bf64a30e1d39\"><li><strong>nodes<\/strong><br>Number of nodes requested<\/li><li><strong>ntasks-per-node<\/strong><br>Number of cores per node. For example, if &#8211;nodes=2 and &#8211;ntasks-per-node=2, then a total of 4 cores will be requested. <\/li><li><strong>ntasks<\/strong><br>Total number of cores regardless of the node number. For example, if &#8211;nodes=2 and &#8211;ntasks=4, then a total number of 4 cores will be requested. It could allocate 1 core on 1 node, 3 cores on the other node, or 2 cores each. <\/li><li><strong>mem-per-cpu<\/strong><br>Memory that is allocated per core for the job. If you exceed this memory limit, your job will be stopped.<\/li><li><strong>mem<\/strong><br>Specify the real memory required per node in MegaBytes. If you exceed this limit, your job will be stopped. Note that for you should ask for less memory than each node actually has.<\/li><li><strong>time<\/strong><br>Maximum walltime the job can run. After this time has expired, the job will be stopped.<\/li><li>j<strong>ob-name<\/strong>&nbsp;The name of the job. Will be reported in the job listing.<\/li><li><strong>partition<\/strong><br>The partition the job should run in. Partitions determine the job\u2019s priority and on what nodes the partition can run on.<\/li><li><strong>error<\/strong><br>Location of the stderr will be written for the job.<\/li><li><strong>output<\/strong><br>Location of the stdout will be written for the job.<\/li><\/ul>\n\n\n\n<p>To submit this job to the cluster, use the <span style=\"color:#cf2e2e\" class=\"tadv-color\">sbatch <\/span>command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sbatch example.slurm<\/code><\/pre>\n\n\n\n<p>SLURM Job Notification<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#SBATCH --mail-user=YOUR_EMAIL_ADDRESS@emory.edu\n#SBATCH --mail-type=ALL #Send all job status to the email address above<\/code><\/pre>\n\n\n\n<p>Valid type values are NONE, BEGIN, END, FAIL, REQUEUE, ALL (equivalent to BEGIN, END, FAIL, REQUEUE, and STAGE_OUT), STAGE_OUT (burst buffer stage out and teardown completed), TIME_LIMIT, TIME_LIMIT_90 (reached 90 percent of time limit), TIME_LIMIT_80 (reached 80 percent of time limit), TIME_LIMIT_50 (reached 50 percent of time limit) and ARRAY_TASKS (send emails for each array task). Multiple type values may be specified in a comma separated list.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are new to the command-line interface (CLI) and do not know how to edit files in CLI, please refer to this page for a tutorial of using the text editor nano. A SLURM file has two parts: 1) The #SBATCH directives and 2) the commands you want to execute within the job. Here &#8230; <a title=\"How to create a SLURM file?\" class=\"read-more\" href=\"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/how-to-create-a-slurm-file\/\" aria-label=\"Read more about How to create a SLURM file?\">Read more<\/a><\/p>\n","protected":false},"author":7027,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-87","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/pages\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/users\/7027"}],"replies":[{"embeddable":true,"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":13,"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/pages\/87\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/pages\/87\/revisions\/265"}],"wp:attachment":[{"href":"https:\/\/scholarblogs.emory.edu\/rsph-hpc\/wp-json\/wp\/v2\/media?parent=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}