This shows you the differences between two versions of the page.
cluster:62 [2007/12/21 14:08] |
cluster:62 [2007/12/21 14:08] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | \\ | ||
+ | **[[cluster: | ||
+ | |||
+ | |||
+ | ====== Automated Submissions ====== | ||
+ | |||
+ | Quanli walked into the office with a request: how can one automate the submission of tons of jobs? In his case Gaussian jobs. "Job Arrays" | ||
+ | |||
+ | However, we took an approach to write a script that generates the job files for you. The basic idea is build a template. | ||
+ | |||
+ | I'm including the simple scripts and steps below (files are in / | ||
+ | |||
+ | |||
+ | |||
+ | ====== Script Approach ====== | ||
+ | |||
+ | First you need to create the input data files. | ||
+ | |||
+ | Next we build a template for the job files we want to generate. | ||
+ | |||
+ | * file '' | ||
+ | |||
+ | < | ||
+ | |||
+ | #!/bin/bash | ||
+ | # TEMPLATE | ||
+ | |||
+ | #BSUB -q QQQ | ||
+ | #BSUB -n NNN | ||
+ | #BSUB -J JJJ | ||
+ | #BSUB -o OOO | ||
+ | #BSUB -e EEE | ||
+ | |||
+ | MYSANSCRATCH=/ | ||
+ | MYLOCALSCRATCH=/ | ||
+ | export MYSANSCRATCH MYLOCALSCRATCH | ||
+ | cd $MYSANSCRATCH | ||
+ | |||
+ | export GAUSS_SCRDIR=" | ||
+ | export g03root="/ | ||
+ | . $g03root/ | ||
+ | |||
+ | cp PPP/in.III ./in | ||
+ | g03 < ./in > ./out | ||
+ | cp ./out PPP/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | Here is the simple script that will generate our job files. | ||
+ | |||
+ | * file '' | ||
+ | |||
+ | < | ||
+ | # | ||
+ | |||
+ | if ($#ARGV == 1) { | ||
+ | $q = $ARGV[0]; | ||
+ | $n = $ARGV[1]; | ||
+ | print " | ||
+ | print "Using user defined values of q=$q, -n=$n\n"; | ||
+ | } else { | ||
+ | print " | ||
+ | print " | ||
+ | $q = elw; | ||
+ | $n = 1; | ||
+ | } | ||
+ | |||
+ | |||
+ | # load template into memory | ||
+ | open(F," | ||
+ | while (<F>) { | ||
+ | push @T, $_; | ||
+ | } | ||
+ | close F; | ||
+ | |||
+ | # how many input files | ||
+ | $t = ` ls in.* | wc -l`; | ||
+ | chop($t); | ||
+ | print " | ||
+ | |||
+ | # where are we | ||
+ | $p = `pwd`; | ||
+ | chop($p); | ||
+ | |||
+ | # build job files for bsub | ||
+ | foreach $i (1..$t) { | ||
+ | undef $ss; | ||
+ | foreach $j (2..$#T) { | ||
+ | $s = $T[$j]; | ||
+ | $s =~ s/QQQ/$q/g; | ||
+ | $s =~ s/NNN/$n/g; | ||
+ | $s =~ s/ | ||
+ | $s =~ s/ | ||
+ | $s =~ s/ | ||
+ | $s =~ s/III/$i/g; | ||
+ | $s =~ s/PPP/$p/g; | ||
+ | $ss .= $s; | ||
+ | } | ||
+ | open(O,"> | ||
+ | print O "# | ||
+ | close O; | ||
+ | } | ||
+ | print " | ||
+ | |||
+ | # lazy, build a submit script | ||
+ | open(O,"> | ||
+ | print O "# | ||
+ | close O; | ||
+ | `chmod u+x build.submit`; | ||
+ | |||
+ | print "Done. Verify a job file, then submit like so ' | ||
+ | </ | ||
+ | |||
+ | Here is how it works. Step by step. | ||
+ | |||
+ | < | ||
+ | |||
+ | [hmeij@swallowtail batch]$ newgrp gaussian | ||
+ | |||
+ | [hmeij@swallowtail batch]$ ll | ||
+ | total 28 | ||
+ | -rwxr--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | |||
+ | [hmeij@swallowtail batch]$ ./ | ||
+ | Usage: ./ | ||
+ | Using default of q=elw, -n=1 | ||
+ | Found 5 input data files. | ||
+ | Build 5 job files. | ||
+ | Done. Verify a job file, then submit like so ' | ||
+ | |||
+ | [hmeij@swallowtail batch]$ cat job.3 | ||
+ | #!/bin/bash | ||
+ | |||
+ | #BSUB -q elw | ||
+ | #BSUB -n 1 | ||
+ | #BSUB -J job.3 | ||
+ | #BSUB -o out.3 | ||
+ | #BSUB -e err.3 | ||
+ | |||
+ | MYSANSCRATCH=/ | ||
+ | MYLOCALSCRATCH=/ | ||
+ | export MYSANSCRATCH MYLOCALSCRATCH | ||
+ | cd $MYSANSCRATCH | ||
+ | |||
+ | export GAUSS_SCRDIR=" | ||
+ | export g03root="/ | ||
+ | . $g03root/ | ||
+ | |||
+ | cp / | ||
+ | g03 < ./in > ./out | ||
+ | cp ./out / | ||
+ | |||
+ | [hmeij@swallowtail batch]$ ./ | ||
+ | Job < | ||
+ | Job < | ||
+ | Job < | ||
+ | Job < | ||
+ | Job < | ||
+ | |||
+ | [hmeij@swallowtail batch]$ bjobs | ||
+ | JOBID | ||
+ | 34529 | ||
+ | 34530 | ||
+ | 34531 | ||
+ | 34532 | ||
+ | 34533 | ||
+ | |||
+ | [hmeij@swallowtail batch]$ ll | ||
+ | total 132 | ||
+ | -rwxr--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rwxr--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ====== Job Arrays ====== | ||
+ | |||
+ | Well this turned out to be easier than expected. | ||
+ | |||
+ | First you may wish to read | ||
+ | |||
+ | * **[[cluster: | ||
+ | |||
+ | or | ||
+ | |||
+ | * **[[http:// | ||
+ | |||
+ | When using job arrays, you submit a single job which contains many tasks. | ||
+ | |||
+ | Here is one way it could work using the Gaussian example mentioned above. | ||
+ | |||
+ | That program file, named '' | ||
+ | |||
+ | Not clear? Here is how it works. | ||
+ | |||
+ | * file '' | ||
+ | |||
+ | < | ||
+ | %mem=1GB | ||
+ | %nproc=1 | ||
+ | # hf/3-21g geom=connectivity | ||
+ | |||
+ | Title Card Required | ||
+ | |||
+ | 0 1 | ||
+ | N | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | 1 2 1.0 3 1.0 4 1.0 | ||
+ | 2 | ||
+ | 3 | ||
+ | 4 | ||
+ | </ | ||
+ | |||
+ | * file '' | ||
+ | |||
+ | < | ||
+ | 1 | ||
+ | </ | ||
+ | |||
+ | * program file '' | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | read i | ||
+ | echo i:$i | ||
+ | echo ' | ||
+ | |||
+ | MYSANSCRATCH=/ | ||
+ | MYLOCALSCRATCH=/ | ||
+ | export MYSANSCRATCH MYLOCALSCRATCH | ||
+ | |||
+ | export GAUSS_SCRDIR=" | ||
+ | export g03root="/ | ||
+ | . $g03root/ | ||
+ | |||
+ | cp ./in.$i $MYSANSCRATCH/ | ||
+ | cd $MYSANSCRATCH | ||
+ | # note that we capture gaussian output as standard out | ||
+ | g03 < ./in | ||
+ | |||
+ | </ | ||
+ | |||
+ | Here is the submission. Step by step. **NOTE THE JOBID THAT GETS ASSIGNED** ... 34554 ... it is the same for all tasks within this job. That makes it easy to manage hundreds or thousands of jobs if you would need to for example stop them all with '' | ||
+ | |||
+ | < | ||
+ | |||
+ | [hmeij@swallowtail arrays]$ newgrp gaussian | ||
+ | |||
+ | [hmeij@swallowtail arrays]$ ll | ||
+ | total 44 | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rwxr--r-- | ||
+ | |||
+ | [hmeij@swallowtail arrays]$ bsub -q elw -n 1 -J " | ||
+ | Job < | ||
+ | |||
+ | [hmeij@swallowtail arrays]$ bjobs | ||
+ | JOBID | ||
+ | 34554 | ||
+ | 34554 | ||
+ | 34554 | ||
+ | 34554 | ||
+ | 34554 | ||
+ | |||
+ | [hmeij@swallowtail arrays]$ ll | ||
+ | total 124 | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rwxr--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | |||
+ | </ | ||
+ | |||
+ | Ofcourse you could pass more information in your array job. For example, you could pass a tilde delimited string of many variables you need to set up your individual tasks. | ||
+ | |||
+ | \\ | ||
+ | **[[cluster: |