15
15
* In a more manual way using the :command:`ipcontroller` and
16
16
:command:`ipengine` commands.
18
This document describes both of these methods. We recommend that new users start with the :command:`ipcluster` command as it simplifies many common usage cases.
18
This document describes both of these methods. We recommend that new users
19
start with the :command:`ipcluster` command as it simplifies many common usage
20
22
General considerations
21
23
======================
23
Before delving into the details about how you can start a controller and engines using the various methods, we outline some of the general issues that come up when starting the controller and engines. These things come up no matter which method you use to start your IPython cluster.
25
Before delving into the details about how you can start a controller and
26
engines using the various methods, we outline some of the general issues that
27
come up when starting the controller and engines. These things come up no
28
matter which method you use to start your IPython cluster.
25
Let's say that you want to start the controller on ``host0`` and engines on hosts ``host1``-``hostn``. The following steps are then required:
30
Let's say that you want to start the controller on ``host0`` and engines on
31
hosts ``host1``-``hostn``. The following steps are then required:
27
33
1. Start the controller on ``host0`` by running :command:`ipcontroller` on
41
47
The final step required required to actually use the running controller from a
42
48
client is to move the FURL files :file:`ipcontroller-mec.furl` and
43
49
:file:`ipcontroller-tc.furl` from ``host0`` to the host where the clients will
44
be run. If these file are put into the :file:`~/.ipython/security` directory of the client's host, they will be found automatically. Otherwise, the full path to them has to be passed to the client's constructor.
50
be run. If these file are put into the :file:`~/.ipython/security` directory
51
of the client's host, they will be found automatically. Otherwise, the full
52
path to them has to be passed to the client's constructor.
46
54
Using :command:`ipcluster`
47
55
==========================
49
The :command:`ipcluster` command provides a simple way of starting a controller and engines in the following situations:
57
The :command:`ipcluster` command provides a simple way of starting a
58
controller and engines in the following situations:
51
60
1. When the controller and engines are all run on localhost. This is useful
52
61
for testing or running on a multicore computer.
110
119
1. Starts the IPython controller on current host.
111
120
2. Uses :command:`mpiexec` to start 4 engines.
113
On newer MPI implementations (such as OpenMPI), this will work even if you don't make any calls to MPI or call :func:`MPI_Init`. However, older MPI implementations actually require each process to call :func:`MPI_Init` upon starting. The easiest way of having this done is to install the mpi4py [mpi4py]_ package and then call ipcluster with the ``--mpi`` option::
122
On newer MPI implementations (such as OpenMPI), this will work even if you
123
don't make any calls to MPI or call :func:`MPI_Init`. However, older MPI
124
implementations actually require each process to call :func:`MPI_Init` upon
125
starting. The easiest way of having this done is to install the mpi4py
126
[mpi4py]_ package and then call ipcluster with the ``--mpi`` option::
115
128
$ ipcluster mpiexec -n 4 --mpi=mpi4py
117
Unfortunately, even this won't work for some MPI implementations. If you are having problems with this, you will likely have to use a custom Python executable that itself calls :func:`MPI_Init` at the appropriate time. Fortunately, mpi4py comes with such a custom Python executable that is easy to install and use. However, this custom Python executable approach will not work with :command:`ipcluster` currently.
130
Unfortunately, even this won't work for some MPI implementations. If you are
131
having problems with this, you will likely have to use a custom Python
132
executable that itself calls :func:`MPI_Init` at the appropriate time.
133
Fortunately, mpi4py comes with such a custom Python executable that is easy to
134
install and use. However, this custom Python executable approach will not work
135
with :command:`ipcluster` currently.
119
137
Additional command line options for this mode can be found by doing::
126
144
Using :command:`ipcluster` in PBS mode
127
145
--------------------------------------
129
The PBS mode uses the Portable Batch System [PBS]_ to start the engines. To use this mode, you first need to create a PBS script template that will be used to start the engines. Here is a sample PBS script template:
147
The PBS mode uses the Portable Batch System [PBS]_ to start the engines. To
148
use this mode, you first need to create a PBS script template that will be
149
used to start the engines. Here is a sample PBS script template:
131
151
.. sourcecode:: bash
161
181
5. Depending on the configuration of you system, you may have to set
162
182
environment variables in the script template.
164
Once you have created such a script, save it with a name like :file:`pbs.template`. Now you are ready to start your job::
184
Once you have created such a script, save it with a name like
185
:file:`pbs.template`. Now you are ready to start your job::
166
187
$ ipcluster pbs -n 128 --pbs-script=pbs.template
175
196
The SSH mode uses :command:`ssh` to execute :command:`ipengine` on remote
176
197
nodes and the :command:`ipcontroller` on localhost.
178
When using using this mode it highly recommended that you have set up SSH keys and are using ssh-agent [SSH]_ for password-less logins.
199
When using using this mode it highly recommended that you have set up SSH keys
200
and are using ssh-agent [SSH]_ for password-less logins.
180
To use this mode you need a python file describing the cluster, here is an example of such a "clusterfile":
202
To use this mode you need a python file describing the cluster, here is an
203
example of such a "clusterfile":
182
205
.. sourcecode:: python
187
210
'host3.example.com' : 1,
188
211
'host4.example.com' : 8 }
190
Since this is a regular python file usual python syntax applies. Things to note:
213
Since this is a regular python file usual python syntax applies. Things to
192
216
* The `engines` dict, where the keys is the host we want to run engines on and
193
217
the value is the number of engines to run on that host.
204
228
$ ipcluster ssh --clusterfile /path/to/my/clusterfile.py
207
Two helper shell scripts are used to start and stop :command:`ipengine` on remote hosts:
231
Two helper shell scripts are used to start and stop :command:`ipengine` on
210
235
* engine_killer.sh
212
Defaults for both of these are contained in the source code for :command:`ipcluster`. The default scripts are written to a local file in a tmep directory and then copied to a temp directory on the remote host and executed from there. On most Unix, Linux and OS X systems this is /tmp.
237
Defaults for both of these are contained in the source code for
238
:command:`ipcluster`. The default scripts are written to a local file in a
239
tmep directory and then copied to a temp directory on the remote host and
240
executed from there. On most Unix, Linux and OS X systems this is /tmp.
214
242
The default sshx.sh is the following:
241
269
Using the :command:`ipcontroller` and :command:`ipengine` commands
242
270
==================================================================
244
It is also possible to use the :command:`ipcontroller` and :command:`ipengine` commands to start your controller and engines. This approach gives you full control over all aspects of the startup process.
272
It is also possible to use the :command:`ipcontroller` and :command:`ipengine`
273
commands to start your controller and engines. This approach gives you full
274
control over all aspects of the startup process.
246
276
Starting the controller and engine on your local machine
247
277
--------------------------------------------------------
256
Next, start however many instances of the engine you want using (repeatedly) the command::
286
Next, start however many instances of the engine you want using (repeatedly)
260
The engines should start and automatically connect to the controller using the FURL files in :file:`~./ipython/security`. You are now ready to use the controller and engines from IPython.
291
The engines should start and automatically connect to the controller using the
292
FURL files in :file:`~./ipython/security`. You are now ready to use the
293
controller and engines from IPython.
279
312
slightly more complicated, but the underlying ideas are the same:
281
314
1. Start the controller on a host using :command:`ipcontroller`.
282
2. Copy :file:`ipcontroller-engine.furl` from :file:`~./ipython/security` on the controller's host to the host where the engines will run.
315
2. Copy :file:`ipcontroller-engine.furl` from :file:`~./ipython/security` on
316
the controller's host to the host where the engines will run.
283
317
3. Use :command:`ipengine` on the engine's hosts to start the engines.
285
The only thing you have to be careful of is to tell :command:`ipengine` where the :file:`ipcontroller-engine.furl` file is located. There are two ways you can do this:
319
The only thing you have to be careful of is to tell :command:`ipengine` where
320
the :file:`ipcontroller-engine.furl` file is located. There are two ways you
287
323
* Put :file:`ipcontroller-engine.furl` in the :file:`~./ipython/security`
288
324
directory on the engine's host, where it will be found automatically.