2014 HTCondor An Introduction To Using

Transcription

An Introduction to UsingHTCondor2014Karen Miller

The Team - 2013Established in 1985,to do research and development of distributedhigh-throughput computing2

HT Stands for High ThroughputThroughput: the quantity of work done byan electronic computer in a given period oftime (Dictionary.com)3

HTCondor’s strengths Cycle scavenging works!Very configurable, adaptableSupports strong security methodsInteroperates with many types of computing gridsManages both dedicated CPUs (clusters) and nondedicated resources (desktops) Fault-tolerant: can survive crashes, network outages,any single point of failure4

HTCondor will . Keep an eye on your jobs and keep youposted on their progress Implement your policy on the execution orderof your jobs Log your job's activities Add fault tolerance to your jobs Implement your policy as to when the jobscan run on your desktop5

Our esteemedscientist*, hasplenty ofsimulations todo.* and Karen's cousin?6

Einstein's SimulationSimulate theevolution of thecosmos,assumingvariousproperties.7

Simulation OverviewVarying values for each of:G(the gravitational constant): 100 valuesRμν (the cosmological constant): 100 valuesc(the speed of light): 100 values100 100 100 1,000,000 jobs8

Each job within the simulation: Requires up to 4 GBytes of RAMRequires 20 MBytes of inputRequires 2 – 500 hours of computing timeProduces up to 10 GBytes of outputEstimated total: 15,000,000 CPU hours or 1,700 compute YEARS 10 Petabytes of output9

Albert will be happy, since HTCondor willmake the completion of the entiresimulation easy.10

DefinitionsJob the HTCondor representation of a piece of work like a Unix process can be an element of a workflowClassAd HTCondor’s internal data representationMachine or Resource computers that can do the processing11

More DefinitionsMatchmaking associating a job with a machine resourceCentral Manager central repository for the whole pool does matchmakingSubmit Host the computer from which jobs are submitted toHTCondorExecute Host the computer that runs a job12

Jobs state their needs and preferences: Requirements (needs): I require a Linux x86-64 platform Rank (preferences): I prefer the machine with the most memory I prefer a machine in the botany department13

Machines specify needs and preferences: Requirements (needs): Require that jobs run only when there is nokeyboard activity Never run jobs belonging to Dr. Heisenberg Rank (preferences): I prefer to run Albert’s jobs14

ClassAdsthe language that HTCondoruses to represent informationabout:jobs (job ClassAd),machines (machineClassAd), and programs thatimplement HTCondor'sfunctionality (calleddaemons)15

Part of a Job ClassAdMyTypeString "Job"TargetType "Machine"ClusterId 1ProcID 0IsPhysics TrueOwner "einstein"Cmd "cosmos"IntegerBooleanRequirements (Arch "INTEL")16BooleanExpression

The Magic of MatchmakingThe matchmaker matches job ClassAds withmachine ClassAds, taking into account: Requirements of both the machine and the job Rank of both the job and the machine Priorities, such as those of users and groups17

Getting Started1. Choose a universe for the job2. Make the job batch-ready, whichincludes making the input data availableand accessible3. Create a submit description file4. Run condor submit to put the job(s)in the queue18

1. Choose the Universe controls how HTCondor handlesjobsthe many universesinclude: vanillastandardgridjavaparallelvm19

Using the vanilla Universe Allows running almostany “serial” job Provides automatic filetransfer for input andoutput files Like vanilla ice cream,can be used in just aboutany situation20

2. Make the jobbatch-ready Must be able to run inthe background No interactive input No GUI/window clicks21

Batch-Ready:Standard Input & Output Job can still use stdin (keyboard),stdout (screen) , and stderr , but filesare used instead of the actual devices Similar to Unix shell redirect: ./myprogram input.txt output.txt22

Make the Data Available HTCondor will Transfer data files to the execute host where thejob runs Transfer result files back from the execute hostto the submit host So, place these data files in a place whereHTCondor can access them23

3. Create aSubmit Description File A plain ASCII text file File name extensions are irrelevant,although many use .sub or .submit assuffixes Describes the job Can describe many jobs at once (acluster), each with different input, output,command line arguments, etc.24

Simple Submit Description File# file name is cosmos.sub# Lines beginning with # are comments# Note: the commands on the left are#not case sensitive, but file names#(on the right) are!Universe vanillaExecutable cosmosInput cosmos.inOutput cosmos.outLog cosmos.logQueuePut 1 instance of thejob in the queue25

Input, Output, and Error FilesInput infileRead job’s standard input from infileLike shell command: program infileOutput outfileWrite job’s standard output to outfileLike shell command: program outfileError errorfileWrite job’s standard error to errorfileLike shell command: program 2 errorfile26

Logging the Job's ActivitiesIn the submit description file:log cosmos.log Creates a log of job events, appended withall events as the job executes Good advice: always have a log file27

Sample Portion of Job Log000 (0101.000.000) 05/25 19:10:03 Job submitted from host: 128.105.146.14:1816 .001 (0101.000.000) 05/25 19:12:17 Job executing on host: 128.105.146.14:1026 .005 (0101.000.000) 05/25 19:13:06 Job terminated.(1) Normal termination (return value 0).000, 001, and 005 are examples of event numbers.28

4. Submit the JobRun condor submit, providing the name ofthe submit description file: condor submit cosmos.subSubmitting job(s).1 job(s) submitted to cluster 100.condor submit will parse the submit description file, checking for errors create a ClassAd that describes the job(s) place the job(s) in the queue, which is an atomicoperation, with a two-phase commit

Observe Jobs in the Queue condor q-- Submitter: MITTED2.0heisenberg1/13 13:593.0hawking1/15 19:184.0hawking1/15 19:33.98.0bohr4/5 13:5299.0bohr4/5 13:52100.0einstein4/5 13:55: 128.104.55.9:51883 :RUN TIME ST PRI SIZE CMD0 00:00:00 R 00.0 env0 04:29:33 H 00.0 script.sh0 00:00:00 H 00.0 script.sh0 00:00:00 I0 00:00:00 I0 00:00:00 I0000.00.00.0atoms Hatoms Hcosmos100 jobs; 1 completed, 0 removed, 20 idle, 1 running, 77 held,0 suspended

File TransferTransfer Input Files specifies a list offiles to transfer from the submit machine to theexecute machineTransfer Output Files specifies a list offiles to transfer back from the execute machineto the submit machine. IfTransfer Output Files is not specified,HTCondor will transfer back all new files in theexecute directory. Generally used to limit thenumber files transferred.31

More on File TransferFiles need to get from the submit machine to the execute machine.2 possibilities:1. both machines have access to a shared file system2. machines have separate file systemsShould Transfer Files YES: transfer files to execute host NO: rely on shared file system IF NEEDED: transfer the files, if the submit and executemachine are not in the same file system domain(translation: use shared file system if available)When To Transfer Output ON EXIT: transfer output files only when job completes ON EXIT OR EVICT: transfer output files when job completesor is evicted32

File Transfer Example# changed cosmos.sub fileUniverse Executable Log Transfer Input Files Transfer Output Files Should Transfer Files When To Transfer Output tIF NEEDEDON EXIT

Command Line ArgumentsUniverse vanillaExecutable cosmosArguments -c 299792458 –G 6.673e-112. . .QueueInvokes executable withcosmos –c 299792458 –G 6.673e-112Look at the condor submit man page to seesyntax for Arguments. This example hasargc 5.34

Job Id isClusterId.ProcId()ClassAdattributes A set of related jobs is called a cluster Each cluster has a cluster number, an unsigned integervalue unique to the job queue on a submit host Each individual job within a cluster is given a processnumber, and process numbers always start at zero A Job ID is the cluster number, a period, and theprocess number. Examples: Job ID 20.0cluster 20, process 0 Job IDs: 21.0, 21.1, 21.2cluster 21, processes 0, 1, 235

1 Cluster, 2 JobsUniverse vanillaExecutable cosmosLogInputOutputQueueLogInputOutputQueue cosmos 0.log cosmos 0.in cosmos 0.outjob 102.0 cosmos 1.log cosmos 1.in cosmos 1.outjob 102.136

File OrganizationA logistical nightmare places all input, output,and log files in one directory. 3 files 1,000,000 jobs 3,000,000 files The submit description file is 4,000,000 linesThe directory will be difficult (at best) to evenlook at.37

Better Organization Create a subdirectory for each job, intentionallynamedrun 0, run 1, run 999999 Implement the creation of directories with a program(such as Python or Perl) Create or place input files in each of theserun 0/cosmos.inrun 1/cosmos.in run 999999/cosmos.in The output and log files for each job will becreated by the job, when the job runs.38

Einstein’s simulation directorycosmoscosmos.subrun 0cosmos.inSubmitter or scriptcosmos.outcreates black-fontcosmos.logfilesHTCondorcreatesrun g39

Better Submit Description File# Cluster of 1,000,000 jobsUniverse vanillaExecutable cosmosLog cosmos.logOutput cosmos.outInput cosmos.inInitialDir run 0QueueInitialDir run 1Queuejob 103.0job 103.1This file contains 999,998 more instances ofInitialDir and Queue.40

Queue all 1,000,000 instances of this simulationwith the single command:Queue 100000041

Submit Description File MacrosWithin the submit description file, HTCondor permitsnamed macros: (Process) will be expanded to the process number foreach job in the cluster.For this example, values will be 0 – 999999 for the1,000,000 jobs.42

Using (Process) The initial directory for each job can be specified.InitialDir run (Process)becomesrun 0, run 1, , run 999999 Similarly, command-line arguments may use amacro.Arguments -n (Process)becomes-n 0-n 1 . . .43-n 999999

(Best) Submit Description File# Example: a cluster of 1000000 jobsUniverse vanillaExecutable cosmosLog cosmos.logInput cosmos.inOutput cosmos.outInitialDir run (Process)Queue 100000044

Albert submits the cosmossimulation. Patience required,it will take a while condor submit cosmos.subSubmitting job(s).Logging submit event(s).1000000 job(s) submitted to cluster 104.45

the Job Queue condor q-- Submitter: submit.chtc.wisc.edu : 128.104.55.9:51883 : submit.chtc.wisc.eduIDOWNERSUBMITTEDRUN TIME ST PRI SIZE CMD104.1einstein 4/20 12:08 0 00:00:03 R 0 9.8 cosmos104.2einstein 4/20 12:08 0 00:00:01 I 0 9.8 cosmos104.3einstein 4/20 12:08 0 00:00:00 I 0 9.8 cosmos.104.999998 einstein 4/20 12:08 0 00:00:00 I 0 9.8 cosmos104.999999 einstein 4/20 12:08 0 00:00:00 I 0 9.8 cosmos999999 jobs; 999998 idle, 1 running, 0 held46

HTCondor watches overthe jobs, runs each one tocompletion once, restartingany that do not finish.Time for a cold one!47

More That You Do With HTCondor48

Remove Jobs with condor rm You can only remove jobs that you own Privileged user can remove any jobs root on Linux administrator on Windowscondor rm 4condor rm 4.2condor rm –aRemoves all cluster 4 jobsRemoves only the job withjob ID 4.2Removes all of your jobs.Careful !49

Specify Job Requirements A boolean expression (syntax similar to C or Java) Evaluated with respect to attributes from machineClassAd(s) Must evaluate to True for a match to be madeUniverseExecutable. vanilla mathematicaRequirements ( \HasMathematicaInstalled ? True )Queue 2050

Specify Needed ResourcesItems appended to job Requirementsrequest memory – the amount of memory (inMbytes) that the job needs to avoid excessiveswappingrequest disk – the amount of disk space (inKbytes) that the job needs. Will be sum of spacefor executable, input files, output files andtemporary files. Default is size of initial sandbox(executable plus input files).request cpus – the number of CPUs (cores) thatthe job needs. Defaults to 1.51

Specify Job Rank All matches which meet the requirements can besorted by preference with a Rank expression Numerical Higher rank values match first; a rank of 100 ishigher than a rank of 6 Like Requirements, is evaluated against attributesfrom machine ClassAdsUniverse vanillaExecutable cosmos. . .Rank (KFLOPS*10000) MemoryQueue 100000052

Job Policy Expressions Do not remove if exits with a signal:on exit remove ExitBySignal False Place on hold if exits with nonzero status orran for less than an hour:on exit hold ( (ExitBySignal False) && (ExitSignal ! 0) ) ( (ServerStartTime - JobStartDate) 3600) Place on hold if job has spent more than50% of its time suspended:periodic hold ( CumulativeSuspensionTime (RemoteWallClockTime / 2.0) )53

Lots ofShort-Running JobsStarting a job is somewhat expensive, in termsof time. The situation has improved in thelast several years. 2 items that might help:1. Batch short jobs together- write a wrapper script that will run a set of the jobsin series- the wrapper script becomes the job executable2. There are some configuration variables thatmay be able to help. Contact a staff person formore info.54

Common Problems withJobs

Jobs Are IdleOur scientist runs condor q and finds all hisjobs are idle: condor q-- Submitter: x.cs.wisc.edu : 128.105.121.53:510 :x.cs.wisc.eduID OWNERSUBMITTEDRUN TIME ST PRI SIZE CMD5.0 einstein 4/20 12:23 0 00:00:00 I 09.8 cosmos5.1 einstein 4/20 12:23 0 00:00:00 I 09.8 cosmos5.2 einstein 4/20 12:23 0 00:00:00 I 09.8 cosmos5.3 einstein 4/20 12:23 0 00:00:00 I 09.8 cosmos5.4 einstein 4/20 12:23 0 00:00:00 I 09.8 cosmos5 jobs; 5 idle, 0 running, 0 held56

Exercise a little patience On a busy pool, it can take a whileto match jobs to machines, andthen start the jobs Wait at least a negotiation cycle ortwo, typically a few minutes57

Look in the Job LogThe log will likely contain clues: cat cosmos.log000 (031.000.000) 04/20 14:47:31 Job submitted fromhost: 128.105.121.53:510 .007 (005.000.000) 04/20 15:02:00 Shadow exception!Error from starter on gig06.cs.wisc.edu:Failed to open 3/run 0/cosmos.in' as standard input: Nosuch file or directory (errno 2)0 - Run Bytes Sent By Job0 - Run Bytes Received By Job.58

Check Machines' Status condor NUXLINUXLINUXWINDOWSWINDOWSArchX86 64X86 64X86 64X86 64X86 64X86 64X86 24ActvtyTime0 00:10:131 19:10:361 22:42:200 03:22:100 03:17:000 03:09:140 19:13:495115110 00:24:170 00:45:01Total Owner Claimed Unclaimed Matched Preempting BackfillINTEL/WINDOWSX86 1059

Try: condor q -analyze condor q -analyze 107.5-- Submitter: crane.cs.wisc.edu : 128.105.136.32:61610 : crane.cs.wisc.eduUser priority for max@crane.cs.wisc.edu is notavailable, attempting to analyze without it.--107.005: Run analysis summary. Of 4 machines,0 are rejected by your job's requirements0 reject your job because of their own requirements4 match and are already running your jobs0 match but are serving other users0 are available to run your job60

condor q -analyze 102.1-- Submitter: crane.cs.wisc.edu : 128.105.136.32:61610 : crane.cs.wisc.eduUser priority for max@crane.cs.wisc.edu is notavailable, attempting to analyze without it.--102.001: Run analysis summary. Of 3184 machines,3184 are rejected by your job's requirements0 reject your job because of their own requirements0 match and are already running your jobs0 match but are serving other users0 are available to run your jobWARNING: Be advised:No resources matched request's constraints61

(continued)The Requirements expression for your job is:( TARGET.Arch "X86 64" ) &&( TARGET.OpSys "WINDOWS" ) &&( TARGET.Disk RequestDisk ) &&( TARGET.Memory RequestMemory ) &&( TARGET.HasFileTransfer )Suggestions:Condition---------Machines MatchedSuggestion---------------- ----------1 ( TARGET.OpSys "WINDOWS" ) 0MODIFY TO "LINUX"2 ( TARGET.Arch "X86 64" )31373 ( TARGET.Disk 1 )31844 ( TARGET.Memory ifthenelse(MemoryUsage isntundefined,MemoryUsage,1) )31845 ( TARGET.HasFileTransfer )318462

Learn about available resources condor status –const 'Memory 8192'(no output means no matches) condor status -const 'Memory 4096'NameOpSys ArchStateActivslot1@c001.ch LINUX X86 64 Unclaimed Idleslot2@c001.ch LINUX X86 64 Unclaimed Idleslot3@c001.ch LINUX X86 64 Unclaimed Idleslot1@c002.ch LINUX X86 64 Unclaimed IdleLoadAv0.0000.0000.0000.000MemActvtyTime5980 1 05:35:055980 13 05:37:037988 1 06:00:057988 13 06:03:47Total Owner Claimed Unclaimed Matched PreemptingX86 64/LINUX400400Total40040063

Interact With A Job Perhaps a job is running for much longerthan expected. Is it stuck accessing a file? Is it in an infinite loop? Try condor ssh to job Interactive debugging in Unix Use ps, top, gdb, strace, lsof, Forward ports, X, transfer files, etc. Currently not available on Windows64

Interactive Debug Example condor q-- Submitter: cosmos.phy.wisc.edu : 128.105.165.34:1027 ID1.0OWNERSUBMITTED RUN TIME ST PRI SIZE CMDeinstein 4/15 06:52 1 12:10:05 R 010.0 cosmos1 jobs; 0 idle, 1 running, 0 held condor ssh to job 1.0Welcome to slot4@c025.chtc.wisc.edu!Your condor job is running with pid(s) 15603. gdb –p 15603. . .65

Better thanHere is a sampling of other features totake advantage of.66

After this tutorial, here are some places youmight find help:1. HTCondor manual2. htcondor-users mailing condor-user3. ki4. developers67

The more time a job takes torun, the higher the risk of being preempted by ahigher priority user or job getting kicked off a machine(vacated), because themachine has something elseit prefers to doHTCondor'sstandard universe mayprovide a solution.68

Standard Universe Regularly while the job runs, or when thejob is to be kicked off the machine,HTCondor takes a checkpoint -- thecomplete state of the job. With a checkpoint, the job can bematched to another machine, andcontinue on.69

checkpoint: the entire state of a program saved in afile, such as CPU registers, memory image, I/O,etc.time70

3 Checkpointstime12713

Killed!time3372

Goodput and Badputgoodputbadputtime3373goodput ?

Standard Universe Features Remote system calls (remote I/O) The job can read or write files as if theywere local Programming language independent No source code changes are typicallyrequired, but relinking the executable withHTCondor's standard universe supportlibrary is required.74

How to RelinkPlace condor compile in front of thecommand used to link the job. Examples: condor compile gcc -o myjob myjob.c- OR condor compile f77 -o myjob filea.f fileb.f- OR condor compile make –f MyMakefile75

Limitations HTCondor’s checkpoint mechanism is not at the kernel level. Therefore, a standarduniverse job may not : fork() Use kernel threads Use some forms of IPC, such as pipes andshared memoryMust have access to object code in order torelinkOnly available on some Linux platforms76

Parallel Universe When multiple processes of a single job must berunning at the same time on different machines. Provides a mechanism for controlling parallelalgorithms fault tolerant allows for resources to come and go ideal for computational grid environments Especially for MPI77

MPI Job Submit Description File# MPI job submit description fileuniverse parallelexecutable mp1scriptarguments my mpich linked exe arg1 arg2machine count 4should transfer files YESwhen to transfer output ON EXITtransfer input files my mpich linked exe ParallelShutdownPolicy "WAIT FOR ALL"queue78

MPI jobsNote: HTCondor will probably not schedule all ofthe jobs on the same machine, so considerusing whole machine slotsSee the HTCondor Wiki:Under HOWTO Recipes for configuration, fancytricks,"How to allow some jobs to claim the wholemachine instead of one slot"79

VM Universe A virtual machine instance is the HTCondor job The vm universe offers job sandboxingcheckpoint and migrationsafe elevation of privilegescross-platform submission HTCondor supports VMware, Xen, and KVM Input files can be imported as CD-ROM image When the VM shuts down, the modified diskimage is returned as job output80

Machine Resources areNumerous: The GridGiven access (authorization) to grid resources ,as well as certificates (for authentication) andaccess to Globus or other resources atremote institutions, HTCondor's grid universedoes the trick !81

Grid Universe All specification is in the submit description file Supports many “back end” types:Globus: GT2, ream GCE (Google Compute Engine) 82

Dependenciesbetween jobs that canbe described by aDAG are handled inHTCondor withDAGMan.ABCDInterested? Stay for Kent'stutorial on managing workflowswith DAGMan.83

the Java UniverseMore than java mysimulator Knows which machines have a JVM installed Knows the location, version, and performanceof the JVM on each machine Knows about jar files, etc. Provides more information about Java jobcompletion than just a JVM exit code Program runs in a Java wrapper, allowingHTCondor to report Java exceptions, etc.84

Java Universe Example# sample java universe submit# description fileUniverse javaExecutable Main.classjar files MyLibrary.jarInput infileOutput outfileArguments Main 1 2 3Queue85

In ReviewWith HTCondor’s help, both you andAlbert can: submit jobs manage jobs organize data files identify aspects of universe choice

Thank you!Check us out on the ondor-admin@cs.wisc.edu87

Extra Slides with MoreInformation You Might Want toReference

Email as Feedback HTCondor sends emailabout job events to thesubmitting user Specify one of these inthe submit onNotification completenevererroralwaysDefault in 7.8Default in 7.9 and 8.x

InitialDir Identifies a directory for file input and output. Also provides a directory (on the submit machine) for thejob log, when a full path is not specified. Note: Executable is not relative to InitialDir# Example with InitialDirUniverse vanillaInitialDir /home/einstein/cosmos/runExecutable cosmosNOT relative to InitialDirLog cosmos.logInput cosmos.inOutput cosmos.outError cosmos.errIs relative to InitialDirTransfer Input Files cosmos.datArguments -f cosmos.datQueue

Substitution Macro ( attribute ) will be replaced by the value of thespecified attribute from the machine ClassAdExample:Machine ClassAd has:CosmosData "/local/cosmos/data"Submit description file hasExecutable cosmosRequirements (CosmosData ! UNDEFINED)Arguments -d (CosmosData)Results in the job invocation:cosmos –d /local/cosmos/data

Getting HTCondor Available as a free download from http://research.cs.wisc.edu/htcondorDownload HTCondor for your operatingsystem Available for many modern Unix platforms(including Linux and Apple’s OS/X) Windows, many versions Repositories YUM: RHEL 4, 5, and 6 yum install condor.x86 64 APT: Debian 6 and 7 apt-get install condor

HTCondor Releases Stable and Developer Releases Version numbering scheme similar to that of the(pre 2.6) Linux kernels Numbering: major.minor.release If minor is even (a.b.c): Stable series Very stable, mostly bug fixes Current: 8.0 If minor is odd (a.b.c): Developer series New features, may have some bugs Current: 8.1

General User Commandscondor statuscondor qcondor submitcondor rmcondor priocondor historycondor submit dagcondor checkpointcondor compileView Pool StatusView Job QueueSubmit new JobsRemove JobsChange a User PriorityCompleted Job InfoSubmit new DAGForce taking a checkpointLink HTCondor library with job94

Einstein’s simulation directory cosmos cosmos.sub run_999999 run_0 Submitter or script creates black-font files HTCondor creates purple-font files cosmos.in cosmos.in cosmos.out cosmos.log cosmos.out cosmos.log 39. Better Submit Descri