-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-submit_first_job.html
175 lines (168 loc) · 11.7 KB
/
02-submit_first_job.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: HPC-novice</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<article>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="index.html"><h1 class="title">HPC-novice</h1></a>
<h2 class="subtitle">Submit first job</h2>
<section class="objectives panel panel-warning">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
<li>Submit the hello world example</li>
<li>First exposure to some linux commands</li>
<li>Explain concepts involved</li>
</ul>
</div>
</section>
<p>The typical workflow on an HPC system involves the following steps:</p>
<ul>
<li>Login</li>
<li>Transfer any files or data needed on the system (we’ll get to this later)</li>
<li>Prepare job submission script and submit the job</li>
<li>Monitor job progress (if desired)</li>
<li>Log out (and potentially wait for an email saying your job finished)</li>
</ul>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>Good citizenship</h2>
</div>
<div class="panel-body">
<p>HPC systems are usually shared among large groups of people. This is why it is important to make sure that you use the scheduler rather than running processes on the login nodes. Low impact activities such as editing files, creating job scripts and submitting jobs are fine. If you accidently start a process and need to stop it quickly you can use <code>Ctrl-C</code> to kill it. Some login nodes will automatically kill your process if it uses too many resources on the login nodes and you may get a strong request from your HPC provider to be more careful.</p>
</div>
</aside>
<p>Doing these things in a linux terminal requires several (but not that many) commands to move files around, edit files and work with the scheduler.</p>
<p>In this lesson, we walk through an entire example explaining as we go. In order to have our example job finish quickly, we’ll submit a prepared script and discuss its contents while the job runs.</p>
<p>To get started, log in to your HPC system. You should have a terminal window open waiting for your input.</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>A few linux commands</h2>
</div>
<div class="panel-body">
<p>Linux commands are typically lowercase cryptic abbreviations. The <code>$</code> represents the command prompt waiting for you to type. After typing the command, press the enter key.</p>
<p><code>$ whoami</code> – your username</p>
<p><code>$ pwd</code> – your current directory/folder (print working directory)</p>
<p><code>$ ls</code> – list the contents of your current directory</p>
</div>
</aside>
<p>Next, let’s create a new directory (also called folders) for this lesson material. The name of the folder is up to you, but you’ll want to remember it.</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">mkdir</span> submit_lesson</code></pre>
<p>We can list the contents of our current directory with the <code>ls</code> command (you may have other things in your directory, but make sure the new directory we just created is there:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ls</span></code></pre>
<pre class="output"><code>submit_lesson</code></pre>
<p>Next, we change into the new directory with the <code>cd</code> command:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">cd</span> submit_lesson</code></pre>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>TAB auto-complete</h2>
</div>
<div class="panel-body">
<p>The terminal has a wonderful feature to save you from making typos. After you start to type <code>submit_lesson</code>, say after the <code>su</code>, press the TAB key. It will complete the name of the directory unless you have some other directory that also starts with <code>su</code>. In that case, you can add press TAB again to see the possibilities, then add more letters so that your choice is clear.</p>
</div>
</aside>
<p>Next, we’ll download the example submission files. Don’t worry much about these commands yet. <code>wget</code> is a tool to download files from the internet and <code>tar</code> is a tool much like <code>unzip</code> that unpacks a collection of files. To facilitate copying and pasting the url, here is the link to <code>examples.tar</code> <a href="https://github.com/dbrunson/hpc-novice/raw/gh-pages/examples.tar">https://github.com/dbrunson/hpc-novice/raw/gh-pages/examples.tar</a> (Right-click on the link and choose ‘copy link location’ or something similar.</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">wget</span> https://github.com/dbrunson/hpc-novice/raw/gh-pages/examples.tar</code></pre>
<p>The <code>wget</code> command will have many lines of output showing its progress. When you get a command prompt <code>$</code> back, use <code>tar</code> as below to extract the files:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">tar</span> xvf examples.tar</code></pre>
<p>Let’s check to see if that worked by using <code>ls -F</code>. The <code>-F</code> is a ‘flag’ or command line option to the <code>ls</code> command and it causes subdirectories to have a <code>/</code> at the end of their name.</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">ls</span> -F</code></pre>
<pre class="output"><code>examples/ examples.tar</code></pre>
<p>Let’s navigate into the <code>examples</code> subdirectory and see what’s there:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">cd</span> examples
$ <span class="kw">ls</span></code></pre>
<pre class="output"><code>helloworld.pbs helloworld.sh</code></pre>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>A note on schedulers</h2>
</div>
<div class="panel-body">
<p>There are several schedulers in use on different HPC systems, but they all are fundamentally the same. We’ll go over this in more detail later, but they all will require you to request walltime, the number of nodes, and a few other things followed by the commands to run your job. The most popular schedulers are Slurm, Grid Engine, and Torque/PBS.</p>
</div>
</aside>
<p>Since a scheduled job make take some time to complete, we’ll go ahead and submit this hello world job now so it can be working while we learn about the files.</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">qsub</span> helloworld.pbs</code></pre>
<p>The output from this command will include your <strong>job id number</strong>.</p>
<p>The file <code>helloworld.pbs</code> is called a <strong>submission script</strong>.</p>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>On filenames</h2>
</div>
<div class="panel-body">
<p>Linux does not care about file extensions. (In Windows, for example. the extions <code>.exe</code> signifies an executible file.) In Linux, it is good practice to use meaningful filenames to make your job of reading them and remembering what they are easier. Here we use, by convention or convenience, the extension <code>.pbs</code> for a PBS submission script and <code>.sh</code> for a bash script. Also remember that filenames are case sensitive.</p>
</div>
</aside>
<aside class="callout panel panel-info">
<div class="panel-heading">
<h2><span class="glyphicon glyphicon-pushpin"></span>spaces</h2>
</div>
<div class="panel-body">
<p>You’ll thank yourself later if you never use spaces in filenames or directory names. The underscore is a great substitute.</p>
</div>
</aside>
<p>Let’s look at the jobs running on the cluster. (Cluster is another word for HPC system.)</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">showq</span></code></pre>
<p><strong><em>NOTE:</em></strong> The <code>showq -u</code> and <code>qpeek</code> commands are not much use for this extremely short hello world example. If you do a longer example later, postpone these unil then.</p>
<p>If you just want to see your jobs (if any):</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">showq</span> -u yourusername</code></pre>
<p>If you have a long job running (which we don’t) you can check on the output with <code>qpeek</code>, but you’ll need to know your job id number. If you forgot, use <code>showq -u yourusername</code> to see it. Suppose your job id number is <code>412343</code>, just type:</p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">qpeek</span> 412343</code></pre>
<p>Let’s take a look at the contents of the submission script <code>helloworld.pbs</code>. The three most common ways to do this are with one of these commands: <code>cat</code>, <code>more</code>,and <code>less</code>. You could also open it in a text editor, such as <code>nano</code>, <code>vim</code>, or <code>emacs.</code></p>
<pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">cat</span> helloworld.pbs</code></pre>
<pre class="output"><code>#!/bin/bash
# This is a comment that is just for humans to read
# Lines starting with #PBS are instructions to the scheduler
# Select the queue you want:
#PBS -q express
# Request the number of nodes and the number of
# processors per node
#PBS -l nodes=1:ppn=1
# Request the maximum time that your job could possibly need
#PBS -l walltime=10:00
# This line puts all the output that would have gone to the screen
# into a single file. Some schedulers do this by default.
#PBS -j oe
# This makes sure your job starts in the same directory as
# where you submitted the job.
cd $PBS_O_WORKDIR
# This is the command to run a job
./helloworld.sh</code></pre>
</div>
</div>
</article>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/swcarpentry/lesson-template">Source</a>
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
</body>
</html>