{"id":77,"date":"2019-03-06T11:21:53","date_gmt":"2019-03-06T16:21:53","guid":{"rendered":"http:\/\/psycomp.utsc.utoronto.ca\/support\/?page_id=77"},"modified":"2019-06-21T22:02:13","modified_gmt":"2019-06-22T02:02:13","slug":"sge-to-slurm-conversion","status":"publish","type":"page","link":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/resources\/sge-to-slurm-conversion\/","title":{"rendered":"SGE to SLURM conversion"},"content":{"rendered":"<p><strong>Sun Grid Engine<\/strong> (<strong>SGE<\/strong>) and <strong>SLURM<\/strong> job scheduler concepts are quite similar. Below is a table of some common SGE commands and their SLURM equivalents.<\/p>\n<p>Some common commands and flags in SGE and SLURM with their respective equivalents:<\/p>\n<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>User Commands<\/strong><\/td>\n<td><strong>SGE<\/strong><\/td>\n<td><strong>SLURM<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>Interactive login<\/strong><\/td>\n<td>qlogin<\/td>\n<td>\n<pre>\r\nsrun --pty bash or srun -p \"partition name\" --time=4:0:0 --pty bash. For a quick dev node, just run \"sdev\"<\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td><strong>Job submission<\/strong><\/td>\n<td>qsub [script_file]<\/td>\n<td>sbatch [script_file]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job deletion<\/strong><\/td>\n<td>qdel [job_id]<\/td>\n<td>scancel [job_id]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job status by job<\/strong><\/td>\n<td>qstat -u \\* [-j job_id]<\/td>\n<td>squeue [job_id]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job status by user<\/strong><\/td>\n<td>qstat [-u user_name]<\/td>\n<td>\n<p>squeue -u [user_name]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><strong>Job hold<\/strong><\/td>\n<td>qhold [job_id]<\/td>\n<td>scontrol hold [job_id]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job release<\/strong><\/td>\n<td>qrls [job_id]<\/td>\n<td>scontrol release [job_id]<\/td>\n<\/tr>\n<tr>\n<td><strong>Queue list<\/strong><\/td>\n<td>qconf -sql<\/td>\n<td>squeue<\/td>\n<\/tr>\n<tr>\n<td><strong>List nodes<\/strong><\/td>\n<td>qhost<\/td>\n<td>sinfo -N OR scontrol show nodes<\/td>\n<\/tr>\n<tr>\n<td><strong>Cluster status<\/strong><\/td>\n<td>qhost -q<\/td>\n<td>sinfo<\/td>\n<\/tr>\n<tr>\n<td><strong>GUI<\/strong><\/td>\n<td>qmon<\/td>\n<td>sview<\/td>\n<\/tr>\n<tr>\n<td> <\/td>\n<td> <\/td>\n<td> <\/td>\n<\/tr>\n<tr>\n<td><strong>Environmental<\/strong><\/td>\n<td> <\/td>\n<td> <\/td>\n<\/tr>\n<tr>\n<td><strong>Job ID<\/strong><\/td>\n<td>$JOB_ID<\/td>\n<td>$SLURM_JOBID<\/td>\n<\/tr>\n<tr>\n<td><strong>Submit directory<\/strong><\/td>\n<td>$SGE_O_WORKDIR<\/td>\n<td>$SLURM_SUBMIT_DIR<\/td>\n<\/tr>\n<tr>\n<td><strong>Submit host<\/strong><\/td>\n<td>$SGE_O_HOST<\/td>\n<td>$SLURM_SUBMIT_HOST<\/td>\n<\/tr>\n<tr>\n<td><strong>Node list<\/strong><\/td>\n<td>$PE_HOSTFILE<\/td>\n<td>$SLURM_JOB_NODELIST<\/td>\n<\/tr>\n<tr>\n<td><strong>Job Array Index<\/strong><\/td>\n<td>$SGE_TASK_ID<\/td>\n<td>$SLURM_ARRAY_TASK_ID<\/td>\n<\/tr>\n<tr>\n<td> <\/td>\n<td> <\/td>\n<td> <\/td>\n<\/tr>\n<tr>\n<td><strong>Job Specification<\/strong><\/td>\n<td> <\/td>\n<td> <\/td>\n<\/tr>\n<tr>\n<td><strong>Script directive<\/strong><\/td>\n<td>#$<\/td>\n<td>#SBATCH<\/td>\n<\/tr>\n<tr>\n<td><strong>queue<\/strong><\/td>\n<td>-q [queue]<\/td>\n<td>-p [queue]<\/td>\n<\/tr>\n<tr>\n<td><strong>count of nodes<\/strong><\/td>\n<td>N\/A<\/td>\n<td>-N [min[-max]]<\/td>\n<\/tr>\n<tr>\n<td><strong>CPU count<\/strong><\/td>\n<td>-pe [PE] [count]<\/td>\n<td>-n [count]<\/td>\n<\/tr>\n<tr>\n<td><strong>Wall clock limit<\/strong><\/td>\n<td>-l h_rt=[seconds]<\/td>\n<td>-t [min] OR -t [days-hh:mm:ss]<\/td>\n<\/tr>\n<tr>\n<td><strong>Standard out file<\/strong><\/td>\n<td>-o [file_name]<\/td>\n<td>-o [file_name]<\/td>\n<\/tr>\n<tr>\n<td><strong>Standard error file<\/strong><\/td>\n<td>-e [file_name]<\/td>\n<td>e [file_name]<\/td>\n<\/tr>\n<tr>\n<td><strong>Combine STDOUT &amp; STDERR files <\/strong><\/td>\n<td>-j yes<\/td>\n<td>(use -o without -e)<\/td>\n<\/tr>\n<tr>\n<td><strong>Copy environment<\/strong><\/td>\n<td>-V<\/td>\n<td>&#8211;export=[ALL | NONE | variables]<\/td>\n<\/tr>\n<tr>\n<td><strong>Event notification<\/strong><\/td>\n<td>-m abe<\/td>\n<td>&#8211;mail-type=[events]<\/td>\n<\/tr>\n<tr>\n<td><strong>send notification email<\/strong><\/td>\n<td>-M [address]<\/td>\n<td>&#8211;mail-user=[address]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job name<\/strong><\/td>\n<td>-N [name]<\/td>\n<td>&#8211;job-name=[name]<\/td>\n<\/tr>\n<tr>\n<td><strong>Restart job<\/strong><\/td>\n<td>-r [yes|no]<\/td>\n<td>&#8211;requeue OR &#8211;no-requeue (NOTE:<br \/>\n\t\t\t\tconfigurable default)<\/td>\n<\/tr>\n<tr>\n<td><strong>Set working directory<\/strong><\/td>\n<td>-wd [directory]<\/td>\n<td>&#8211;workdir=[dir_name]<\/td>\n<\/tr>\n<tr>\n<td><strong>Resource sharing<\/strong><\/td>\n<td>-l exclusive<\/td>\n<td>&#8211;exclusive OR&#8211;shared<\/td>\n<\/tr>\n<tr>\n<td><strong>Memory size<\/strong><\/td>\n<td>-l mem_free=[memory][K|M|G]<\/td>\n<td>&#8211;mem=[mem][M|G|T] OR &#8211;mem-per-cpu=<br \/>\n\t\t\t\t[mem][M|G|T]<\/td>\n<\/tr>\n<tr>\n<td><strong>Charge to an account<\/strong><\/td>\n<td>-A [account]<\/td>\n<td>&#8211;account=[account]<\/td>\n<\/tr>\n<tr>\n<td><strong>Tasks per node<\/strong><\/td>\n<td>(Fixed allocation_rule in PE)<\/td>\n<td>&#8211;tasks-per-node=[count]<\/td>\n<\/tr>\n<tr>\n<td> <\/td>\n<td> <\/td>\n<td>&#8211;cpus-per-task=[count]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job dependancy<\/strong><\/td>\n<td>-hold_jid [job_id | job_name]<\/td>\n<td>&#8211;depend=[state:job_id]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job project<\/strong><\/td>\n<td>-P [name]<\/td>\n<td>&#8211;wckey=[name]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job host preference<\/strong><\/td>\n<td>-q [queue]@[node] OR -q<br \/>\n\t\t\t\t[queue]@@[hostgroup]<\/td>\n<td>&#8211;nodelist=[nodes] AND\/OR &#8211;exclude=<br \/>\n\t\t\t\t[nodes]<\/td>\n<\/tr>\n<tr>\n<td><strong>Quality of service<\/strong><\/td>\n<td> <\/td>\n<td>&#8211;qos=[name]<\/td>\n<\/tr>\n<tr>\n<td><strong>Job arrays<\/strong><\/td>\n<td>-t [array_spec]<\/td>\n<td>&#8211;array=[array_spec] (Slurm version 2.6+)<\/td>\n<\/tr>\n<tr>\n<td><strong>Generic Resources<\/strong><\/td>\n<td>-l [resource]=[value]<\/td>\n<td>&#8211;gres=[resource_spec]<\/td>\n<\/tr>\n<tr>\n<td><strong>Lincenses<\/strong><\/td>\n<td>-l [license]=[count]<\/td>\n<td>&#8211;licenses=[license_spec]<\/td>\n<\/tr>\n<tr>\n<td><strong>Begin Time<\/strong><\/td>\n<td>-a [YYMMDDhhmm]<\/td>\n<td>&#8211;begin=YYYY-MM-DD[THH:MM[:SS]]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<tbody>\n<tr>\n<th><strong>SGE<\/strong><\/th>\n<th><strong>SLURM<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<tbody>\n<tr>\n<td>qstat<\/p>\n<blockquote><p>qstat -u username<br \/>\n\t\t\t\t\tqstat -f<\/p><\/blockquote>\n<\/td>\n<td>squeue<\/p>\n<blockquote><p>squeue -u username<br \/>\n\t\t\t\t\tsqueue -al<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<tr>\n<td>qsub<\/p>\n<blockquote><p>qsub -N jobname<br \/>\n\t\t\t\t\tqsub -l h_rt=24:00:00<br \/>\n\t\t\t\t\tqsub -pe dmp4 16<br \/>\n\t\t\t\t\tqsub -l mem=4G<br \/>\n\t\t\t\t\tqsub -o filename<br \/>\n\t\t\t\t\tqsub -e filename<br \/>\n\t\t\t\t\tqsub -l scratch_free=20G<\/p><\/blockquote>\n<\/td>\n<td>sbatch<\/p>\n<blockquote><p>sbatch -J jobname<br \/>\n\t\t\t\t\tsbatch -t 24:00:00<br \/>\n\t\t\t\t\tsbatch -p node -n 16<\/p><\/blockquote>\n<blockquote><p>sbatch &#8211;mem=4000<br \/>\n\t\t\t\t\tsbatch -o filename<br \/>\n\t\t\t\t\tsbatch -e filename<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<tr>\n<td># Interactive run, one core<\/td>\n<td># Interactive run, one core<\/td>\n<\/tr>\n<tr>\n<td>qrsh -l h_rt=8:00:00<\/td>\n<td>salloc -t 8:00:00<br \/>\n\t\t\t\tinteractive -p core -n 1 -t 8:00:00<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tqdel<\/td>\n<td>\n\t\t\t\tscancel<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/p>\n<table>\n<tbody>\n<tr>\n<th><strong>SGE for a single-core application<\/strong><\/th>\n<th><strong>SLURM for a single-core application<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<tbody>\n<tr>\n<td>\n<div>\n<pre>\r\n<span>#!\/bin\/bash<\/span>\r\n<span>#<\/span>\r\n<span>#<\/span>\r\n<span>#$ -N test<\/span>\r\n<span>#$ -j y<\/span>\r\n<span>#$ -o test.output<\/span>\r\n<span>#$ -cwd<\/span>\r\n<span>#$ -M $USER@stanford.edu<\/span>\r\n<span>#$ -m bea<\/span>\r\n<span># Request 5 hours run time<\/span>\r\n<span>#$ -l h_rt=5:0:0<\/span>\r\n<span>#$ -P your_project_id_here<\/span>\r\n<span>#<\/span>\r\n<span>#$ -l mem=4G<\/span>\r\n<span># <\/span>\r\n \r\n<span>&lt;<\/span>call your app here<span>&gt;<\/span><\/pre>\n<\/p><\/div>\n<\/td>\n<td>\n<div>\n<pre>\r\n<span>#!\/bin\/bash -l<\/span>\r\n<span># NOTE the -l flag!<\/span>\r\n<span>#<\/span>\r\n<span>#SBATCH -J tes<\/span>t\r\n<span>#SBATCH -o test.\"%j\".out<\/span>\r\n<span>#SBATCH -e test.\"%j\".err<\/span>\r\n<span># Default in slurm<\/span>\r\n<span>#SBATCH --mail-user $USER@stanford.edu<\/span>\r\n<span>#SBATCH --mail-type=ALL<\/span>\r\n<span># Request 5 hours run time<\/span>\r\n<span>#SBATCH -t 5:0:0<\/span>\r\n<span>#SBATCH --mem=4000<\/span>\r\n<span>#SBATCH -p normal<\/span>\r\n\r\n \r\n<span>&lt;<\/span>load modules, call your app here<span>&gt;<\/span><\/pre>\n<\/p><\/div>\n<\/td>\n<\/tr>\n<tr>\n<td> <\/td>\n<td> <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Comparison of some parallel environments set by sge and slurm<\/p>\n<table>\n<tbody>\n<tr>\n<th><strong>SGE<\/strong><\/th>\n<th><strong>SLURM<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<tbody>\n<tr>\n<td>$JOB_ID<\/td>\n<td>$SLURM_JOB_ID<\/td>\n<\/tr>\n<tr>\n<td>$NSLOTS<\/td>\n<td>$SLURM_NPROCS<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sun Grid Engine (SGE) and SLURM job scheduler concepts are quite similar. Below is a table of some common SGE commands and their SLURM equivalents. Some common commands and flags in SGE and SLURM with their respective equivalents: User Commands SGE SLURM Interactive login qlogin srun &#8211;pty bash or srun -p &#8220;partition name&#8221; &#8211;time=4:0:0 &#8211;pty &hellip; <a href=\"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/resources\/sge-to-slurm-conversion\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;SGE to SLURM conversion&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":50,"menu_order":100,"comment_status":"closed","ping_status":"closed","template":"full-width-page.php","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-77","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/pages\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":11,"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/pages\/77\/revisions"}],"predecessor-version":[{"id":861,"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/pages\/77\/revisions\/861"}],"up":[{"embeddable":true,"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/pages\/50"}],"wp:attachment":[{"href":"https:\/\/psycomp.utsc.utoronto.ca\/support\/index.php\/wp-json\/wp\/v2\/media?parent=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}