Show More
@@ -1,360 +1,360 b'' | |||||
1 | ============================================ |
|
1 | ============================================ | |
2 | Getting started with Windows HPC Server 2008 |
|
2 | Getting started with Windows HPC Server 2008 | |
3 | ============================================ |
|
3 | ============================================ | |
4 |
|
4 | |||
5 | Introduction |
|
5 | Introduction | |
6 | ============ |
|
6 | ============ | |
7 |
|
7 | |||
8 | The Python programming language is an increasingly popular language for |
|
8 | The Python programming language is an increasingly popular language for | |
9 | numerical computing. This is due to a unique combination of factors. First, |
|
9 | numerical computing. This is due to a unique combination of factors. First, | |
10 | Python is a high-level and *interactive* language that is well matched to |
|
10 | Python is a high-level and *interactive* language that is well matched to | |
11 | interactive numerical work. Second, it is easy (often times trivial) to |
|
11 | interactive numerical work. Second, it is easy (often times trivial) to | |
12 | integrate legacy C/C++/Fortran code into Python. Third, a large number of |
|
12 | integrate legacy C/C++/Fortran code into Python. Third, a large number of | |
13 | high-quality open source projects provide all the needed building blocks for |
|
13 | high-quality open source projects provide all the needed building blocks for | |
14 | numerical computing: numerical arrays (NumPy), algorithms (SciPy), 2D/3D |
|
14 | numerical computing: numerical arrays (NumPy), algorithms (SciPy), 2D/3D | |
15 | Visualization (Matplotlib, Mayavi, Chaco), Symbolic Mathematics (Sage, Sympy) |
|
15 | Visualization (Matplotlib, Mayavi, Chaco), Symbolic Mathematics (Sage, Sympy) | |
16 | and others. |
|
16 | and others. | |
17 |
|
17 | |||
18 | The IPython project is a core part of this open-source toolchain and is |
|
18 | The IPython project is a core part of this open-source toolchain and is | |
19 | focused on creating a comprehensive environment for interactive and |
|
19 | focused on creating a comprehensive environment for interactive and | |
20 | exploratory computing in the Python programming language. It enables all of |
|
20 | exploratory computing in the Python programming language. It enables all of | |
21 | the above tools to be used interactively and consists of two main components: |
|
21 | the above tools to be used interactively and consists of two main components: | |
22 |
|
22 | |||
23 | * An enhanced interactive Python shell with support for interactive plotting |
|
23 | * An enhanced interactive Python shell with support for interactive plotting | |
24 | and visualization. |
|
24 | and visualization. | |
25 | * An architecture for interactive parallel computing. |
|
25 | * An architecture for interactive parallel computing. | |
26 |
|
26 | |||
27 | With these components, it is possible to perform all aspects of a parallel |
|
27 | With these components, it is possible to perform all aspects of a parallel | |
28 | computation interactively. This type of workflow is particularly relevant in |
|
28 | computation interactively. This type of workflow is particularly relevant in | |
29 | scientific and numerical computing where algorithms, code and data are |
|
29 | scientific and numerical computing where algorithms, code and data are | |
30 | continually evolving as the user/developer explores a problem. The broad |
|
30 | continually evolving as the user/developer explores a problem. The broad | |
31 | treads in computing (commodity clusters, multicore, cloud computing, etc.) |
|
31 | threads in computing (commodity clusters, multicore, cloud computing, etc.) | |
32 | make these capabilities of IPython particularly relevant. |
|
32 | make these capabilities of IPython particularly relevant. | |
33 |
|
33 | |||
34 | While IPython is a cross platform tool, it has particularly strong support for |
|
34 | While IPython is a cross platform tool, it has particularly strong support for | |
35 | Windows based compute clusters running Windows HPC Server 2008. This document |
|
35 | Windows based compute clusters running Windows HPC Server 2008. This document | |
36 | describes how to get started with IPython on Windows HPC Server 2008. The |
|
36 | describes how to get started with IPython on Windows HPC Server 2008. The | |
37 | content and emphasis here is practical: installing IPython, configuring |
|
37 | content and emphasis here is practical: installing IPython, configuring | |
38 | IPython to use the Windows job scheduler and running example parallel programs |
|
38 | IPython to use the Windows job scheduler and running example parallel programs | |
39 | interactively. A more complete description of IPython's parallel computing |
|
39 | interactively. A more complete description of IPython's parallel computing | |
40 | capabilities can be found in IPython's online documentation |
|
40 | capabilities can be found in IPython's online documentation | |
41 | (http://ipython.org/documentation.html). |
|
41 | (http://ipython.org/documentation.html). | |
42 |
|
42 | |||
43 | Setting up your Windows cluster |
|
43 | Setting up your Windows cluster | |
44 | =============================== |
|
44 | =============================== | |
45 |
|
45 | |||
46 | This document assumes that you already have a cluster running Windows |
|
46 | This document assumes that you already have a cluster running Windows | |
47 | HPC Server 2008. Here is a broad overview of what is involved with setting up |
|
47 | HPC Server 2008. Here is a broad overview of what is involved with setting up | |
48 | such a cluster: |
|
48 | such a cluster: | |
49 |
|
49 | |||
50 | 1. Install Windows Server 2008 on the head and compute nodes in the cluster. |
|
50 | 1. Install Windows Server 2008 on the head and compute nodes in the cluster. | |
51 | 2. Setup the network configuration on each host. Each host should have a |
|
51 | 2. Setup the network configuration on each host. Each host should have a | |
52 | static IP address. |
|
52 | static IP address. | |
53 | 3. On the head node, activate the "Active Directory Domain Services" role |
|
53 | 3. On the head node, activate the "Active Directory Domain Services" role | |
54 | and make the head node the domain controller. |
|
54 | and make the head node the domain controller. | |
55 | 4. Join the compute nodes to the newly created Active Directory (AD) domain. |
|
55 | 4. Join the compute nodes to the newly created Active Directory (AD) domain. | |
56 | 5. Setup user accounts in the domain with shared home directories. |
|
56 | 5. Setup user accounts in the domain with shared home directories. | |
57 | 6. Install the HPC Pack 2008 on the head node to create a cluster. |
|
57 | 6. Install the HPC Pack 2008 on the head node to create a cluster. | |
58 | 7. Install the HPC Pack 2008 on the compute nodes. |
|
58 | 7. Install the HPC Pack 2008 on the compute nodes. | |
59 |
|
59 | |||
60 | More details about installing and configuring Windows HPC Server 2008 can be |
|
60 | More details about installing and configuring Windows HPC Server 2008 can be | |
61 | found on the Windows HPC Home Page (http://www.microsoft.com/hpc). Regardless |
|
61 | found on the Windows HPC Home Page (http://www.microsoft.com/hpc). Regardless | |
62 | of what steps you follow to set up your cluster, the remainder of this |
|
62 | of what steps you follow to set up your cluster, the remainder of this | |
63 | document will assume that: |
|
63 | document will assume that: | |
64 |
|
64 | |||
65 | * There are domain users that can log on to the AD domain and submit jobs |
|
65 | * There are domain users that can log on to the AD domain and submit jobs | |
66 | to the cluster scheduler. |
|
66 | to the cluster scheduler. | |
67 | * These domain users have shared home directories. While shared home |
|
67 | * These domain users have shared home directories. While shared home | |
68 | directories are not required to use IPython, they make it much easier to |
|
68 | directories are not required to use IPython, they make it much easier to | |
69 | use IPython. |
|
69 | use IPython. | |
70 |
|
70 | |||
71 | Installation of IPython and its dependencies |
|
71 | Installation of IPython and its dependencies | |
72 | ============================================ |
|
72 | ============================================ | |
73 |
|
73 | |||
74 | IPython and all of its dependencies are freely available and open source. |
|
74 | IPython and all of its dependencies are freely available and open source. | |
75 | These packages provide a powerful and cost-effective approach to numerical and |
|
75 | These packages provide a powerful and cost-effective approach to numerical and | |
76 | scientific computing on Windows. The following dependencies are needed to run |
|
76 | scientific computing on Windows. The following dependencies are needed to run | |
77 | IPython on Windows: |
|
77 | IPython on Windows: | |
78 |
|
78 | |||
79 | * Python 2.6 or 2.7 (http://www.python.org) |
|
79 | * Python 2.6 or 2.7 (http://www.python.org) | |
80 | * pywin32 (http://sourceforge.net/projects/pywin32/) |
|
80 | * pywin32 (http://sourceforge.net/projects/pywin32/) | |
81 | * PyReadline (https://launchpad.net/pyreadline) |
|
81 | * PyReadline (https://launchpad.net/pyreadline) | |
82 | * pyzmq (http://github.com/zeromq/pyzmq/downloads) |
|
82 | * pyzmq (http://github.com/zeromq/pyzmq/downloads) | |
83 | * IPython (http://ipython.org) |
|
83 | * IPython (http://ipython.org) | |
84 |
|
84 | |||
85 | In addition, the following dependencies are needed to run the demos described |
|
85 | In addition, the following dependencies are needed to run the demos described | |
86 | in this document. |
|
86 | in this document. | |
87 |
|
87 | |||
88 | * NumPy and SciPy (http://www.scipy.org) |
|
88 | * NumPy and SciPy (http://www.scipy.org) | |
89 | * Matplotlib (http://matplotlib.sourceforge.net/) |
|
89 | * Matplotlib (http://matplotlib.sourceforge.net/) | |
90 |
|
90 | |||
91 | The easiest way of obtaining these dependencies is through the Enthought |
|
91 | The easiest way of obtaining these dependencies is through the Enthought | |
92 | Python Distribution (EPD) (http://www.enthought.com/products/epd.php). EPD is |
|
92 | Python Distribution (EPD) (http://www.enthought.com/products/epd.php). EPD is | |
93 | produced by Enthought, Inc. and contains all of these packages and others in a |
|
93 | produced by Enthought, Inc. and contains all of these packages and others in a | |
94 | single installer and is available free for academic users. While it is also |
|
94 | single installer and is available free for academic users. While it is also | |
95 | possible to download and install each package individually, this is a tedious |
|
95 | possible to download and install each package individually, this is a tedious | |
96 | process. Thus, we highly recommend using EPD to install these packages on |
|
96 | process. Thus, we highly recommend using EPD to install these packages on | |
97 | Windows. |
|
97 | Windows. | |
98 |
|
98 | |||
99 | Regardless of how you install the dependencies, here are the steps you will |
|
99 | Regardless of how you install the dependencies, here are the steps you will | |
100 | need to follow: |
|
100 | need to follow: | |
101 |
|
101 | |||
102 | 1. Install all of the packages listed above, either individually or using EPD |
|
102 | 1. Install all of the packages listed above, either individually or using EPD | |
103 | on the head node, compute nodes and user workstations. |
|
103 | on the head node, compute nodes and user workstations. | |
104 |
|
104 | |||
105 | 2. Make sure that :file:`C:\\Python27` and :file:`C:\\Python27\\Scripts` are |
|
105 | 2. Make sure that :file:`C:\\Python27` and :file:`C:\\Python27\\Scripts` are | |
106 | in the system :envvar:`%PATH%` variable on each node. |
|
106 | in the system :envvar:`%PATH%` variable on each node. | |
107 |
|
107 | |||
108 | 3. Install the latest development version of IPython. This can be done by |
|
108 | 3. Install the latest development version of IPython. This can be done by | |
109 | downloading the the development version from the IPython website |
|
109 | downloading the the development version from the IPython website | |
110 | (http://ipython.org) and following the installation instructions. |
|
110 | (http://ipython.org) and following the installation instructions. | |
111 |
|
111 | |||
112 | Further details about installing IPython or its dependencies can be found in |
|
112 | Further details about installing IPython or its dependencies can be found in | |
113 | the online IPython documentation (http://ipython.org/documentation.html) |
|
113 | the online IPython documentation (http://ipython.org/documentation.html) | |
114 | Once you are finished with the installation, you can try IPython out by |
|
114 | Once you are finished with the installation, you can try IPython out by | |
115 | opening a Windows Command Prompt and typing ``ipython``. This will |
|
115 | opening a Windows Command Prompt and typing ``ipython``. This will | |
116 | start IPython's interactive shell and you should see something like the |
|
116 | start IPython's interactive shell and you should see something like the | |
117 | following:: |
|
117 | following:: | |
118 |
|
118 | |||
119 | Microsoft Windows [Version 6.0.6001] |
|
119 | Microsoft Windows [Version 6.0.6001] | |
120 | Copyright (c) 2006 Microsoft Corporation. All rights reserved. |
|
120 | Copyright (c) 2006 Microsoft Corporation. All rights reserved. | |
121 |
|
121 | |||
122 | Z:\>ipython |
|
122 | Z:\>ipython | |
123 | Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] |
|
123 | Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] | |
124 | Type "copyright", "credits" or "license" for more information. |
|
124 | Type "copyright", "credits" or "license" for more information. | |
125 |
|
125 | |||
126 | IPython 0.12.dev -- An enhanced Interactive Python. |
|
126 | IPython 0.12.dev -- An enhanced Interactive Python. | |
127 | ? -> Introduction and overview of IPython's features. |
|
127 | ? -> Introduction and overview of IPython's features. | |
128 | %quickref -> Quick reference. |
|
128 | %quickref -> Quick reference. | |
129 | help -> Python's own help system. |
|
129 | help -> Python's own help system. | |
130 | object? -> Details about 'object', use 'object??' for extra details. |
|
130 | object? -> Details about 'object', use 'object??' for extra details. | |
131 |
|
131 | |||
132 | In [1]: |
|
132 | In [1]: | |
133 |
|
133 | |||
134 |
|
134 | |||
135 | Starting an IPython cluster |
|
135 | Starting an IPython cluster | |
136 | =========================== |
|
136 | =========================== | |
137 |
|
137 | |||
138 | To use IPython's parallel computing capabilities, you will need to start an |
|
138 | To use IPython's parallel computing capabilities, you will need to start an | |
139 | IPython cluster. An IPython cluster consists of one controller and multiple |
|
139 | IPython cluster. An IPython cluster consists of one controller and multiple | |
140 | engines: |
|
140 | engines: | |
141 |
|
141 | |||
142 | IPython controller |
|
142 | IPython controller | |
143 | The IPython controller manages the engines and acts as a gateway between |
|
143 | The IPython controller manages the engines and acts as a gateway between | |
144 | the engines and the client, which runs in the user's interactive IPython |
|
144 | the engines and the client, which runs in the user's interactive IPython | |
145 | session. The controller is started using the :command:`ipcontroller` |
|
145 | session. The controller is started using the :command:`ipcontroller` | |
146 | command. |
|
146 | command. | |
147 |
|
147 | |||
148 | IPython engine |
|
148 | IPython engine | |
149 | IPython engines run a user's Python code in parallel on the compute nodes. |
|
149 | IPython engines run a user's Python code in parallel on the compute nodes. | |
150 | Engines are starting using the :command:`ipengine` command. |
|
150 | Engines are starting using the :command:`ipengine` command. | |
151 |
|
151 | |||
152 | Once these processes are started, a user can run Python code interactively and |
|
152 | Once these processes are started, a user can run Python code interactively and | |
153 | in parallel on the engines from within the IPython shell using an appropriate |
|
153 | in parallel on the engines from within the IPython shell using an appropriate | |
154 | client. This includes the ability to interact with, plot and visualize data |
|
154 | client. This includes the ability to interact with, plot and visualize data | |
155 | from the engines. |
|
155 | from the engines. | |
156 |
|
156 | |||
157 | IPython has a command line program called :command:`ipcluster` that automates |
|
157 | IPython has a command line program called :command:`ipcluster` that automates | |
158 | all aspects of starting the controller and engines on the compute nodes. |
|
158 | all aspects of starting the controller and engines on the compute nodes. | |
159 | :command:`ipcluster` has full support for the Windows HPC job scheduler, |
|
159 | :command:`ipcluster` has full support for the Windows HPC job scheduler, | |
160 | meaning that :command:`ipcluster` can use this job scheduler to start the |
|
160 | meaning that :command:`ipcluster` can use this job scheduler to start the | |
161 | controller and engines. In our experience, the Windows HPC job scheduler is |
|
161 | controller and engines. In our experience, the Windows HPC job scheduler is | |
162 | particularly well suited for interactive applications, such as IPython. Once |
|
162 | particularly well suited for interactive applications, such as IPython. Once | |
163 | :command:`ipcluster` is configured properly, a user can start an IPython |
|
163 | :command:`ipcluster` is configured properly, a user can start an IPython | |
164 | cluster from their local workstation almost instantly, without having to log |
|
164 | cluster from their local workstation almost instantly, without having to log | |
165 | on to the head node (as is typically required by Unix based job schedulers). |
|
165 | on to the head node (as is typically required by Unix based job schedulers). | |
166 | This enables a user to move seamlessly between serial and parallel |
|
166 | This enables a user to move seamlessly between serial and parallel | |
167 | computations. |
|
167 | computations. | |
168 |
|
168 | |||
169 | In this section we show how to use :command:`ipcluster` to start an IPython |
|
169 | In this section we show how to use :command:`ipcluster` to start an IPython | |
170 | cluster using the Windows HPC Server 2008 job scheduler. To make sure that |
|
170 | cluster using the Windows HPC Server 2008 job scheduler. To make sure that | |
171 | :command:`ipcluster` is installed and working properly, you should first try |
|
171 | :command:`ipcluster` is installed and working properly, you should first try | |
172 | to start an IPython cluster on your local host. To do this, open a Windows |
|
172 | to start an IPython cluster on your local host. To do this, open a Windows | |
173 | Command Prompt and type the following command:: |
|
173 | Command Prompt and type the following command:: | |
174 |
|
174 | |||
175 | ipcluster start -n 2 |
|
175 | ipcluster start -n 2 | |
176 |
|
176 | |||
177 | You should see a number of messages printed to the screen. |
|
177 | You should see a number of messages printed to the screen. | |
178 | The result should look something like this:: |
|
178 | The result should look something like this:: | |
179 |
|
179 | |||
180 | Microsoft Windows [Version 6.1.7600] |
|
180 | Microsoft Windows [Version 6.1.7600] | |
181 | Copyright (c) 2009 Microsoft Corporation. All rights reserved. |
|
181 | Copyright (c) 2009 Microsoft Corporation. All rights reserved. | |
182 |
|
182 | |||
183 | Z:\>ipcluster start --profile=mycluster |
|
183 | Z:\>ipcluster start --profile=mycluster | |
184 | [IPClusterStart] Using existing profile dir: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster' |
|
184 | [IPClusterStart] Using existing profile dir: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster' | |
185 | [IPClusterStart] Starting ipcluster with [daemon=False] |
|
185 | [IPClusterStart] Starting ipcluster with [daemon=False] | |
186 | [IPClusterStart] Creating pid file: \\blue\domainusers$\bgranger\.ipython\profile_mycluster\pid\ipcluster.pid |
|
186 | [IPClusterStart] Creating pid file: \\blue\domainusers$\bgranger\.ipython\profile_mycluster\pid\ipcluster.pid | |
187 | [IPClusterStart] Writing job description file: \\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipcontroller_job.xml |
|
187 | [IPClusterStart] Writing job description file: \\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipcontroller_job.xml | |
188 | [IPClusterStart] Starting Win HPC Job: job submit /jobfile:\\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipcontroller_job.xml /scheduler:HEADNODE |
|
188 | [IPClusterStart] Starting Win HPC Job: job submit /jobfile:\\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipcontroller_job.xml /scheduler:HEADNODE | |
189 | [IPClusterStart] Starting 15 engines |
|
189 | [IPClusterStart] Starting 15 engines | |
190 | [IPClusterStart] Writing job description file: \\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipcontroller_job.xml |
|
190 | [IPClusterStart] Writing job description file: \\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipcontroller_job.xml | |
191 | [IPClusterStart] Starting Win HPC Job: job submit /jobfile:\\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipengineset_job.xml /scheduler:HEADNODE |
|
191 | [IPClusterStart] Starting Win HPC Job: job submit /jobfile:\\blue\domainusers$\bgranger\.ipython\profile_mycluster\ipengineset_job.xml /scheduler:HEADNODE | |
192 |
|
192 | |||
193 |
|
193 | |||
194 | At this point, the controller and two engines are running on your local host. |
|
194 | At this point, the controller and two engines are running on your local host. | |
195 | This configuration is useful for testing and for situations where you want to |
|
195 | This configuration is useful for testing and for situations where you want to | |
196 | take advantage of multiple cores on your local computer. |
|
196 | take advantage of multiple cores on your local computer. | |
197 |
|
197 | |||
198 | Now that we have confirmed that :command:`ipcluster` is working properly, we |
|
198 | Now that we have confirmed that :command:`ipcluster` is working properly, we | |
199 | describe how to configure and run an IPython cluster on an actual compute |
|
199 | describe how to configure and run an IPython cluster on an actual compute | |
200 | cluster running Windows HPC Server 2008. Here is an outline of the needed |
|
200 | cluster running Windows HPC Server 2008. Here is an outline of the needed | |
201 | steps: |
|
201 | steps: | |
202 |
|
202 | |||
203 | 1. Create a cluster profile using: ``ipython profile create mycluster --parallel`` |
|
203 | 1. Create a cluster profile using: ``ipython profile create mycluster --parallel`` | |
204 |
|
204 | |||
205 | 2. Edit configuration files in the directory :file:`.ipython\\cluster_mycluster` |
|
205 | 2. Edit configuration files in the directory :file:`.ipython\\cluster_mycluster` | |
206 |
|
206 | |||
207 | 3. Start the cluster using: ``ipcluster start --profile=mycluster -n 32`` |
|
207 | 3. Start the cluster using: ``ipcluster start --profile=mycluster -n 32`` | |
208 |
|
208 | |||
209 | Creating a cluster profile |
|
209 | Creating a cluster profile | |
210 | -------------------------- |
|
210 | -------------------------- | |
211 |
|
211 | |||
212 | In most cases, you will have to create a cluster profile to use IPython on a |
|
212 | In most cases, you will have to create a cluster profile to use IPython on a | |
213 | cluster. A cluster profile is a name (like "mycluster") that is associated |
|
213 | cluster. A cluster profile is a name (like "mycluster") that is associated | |
214 | with a particular cluster configuration. The profile name is used by |
|
214 | with a particular cluster configuration. The profile name is used by | |
215 | :command:`ipcluster` when working with the cluster. |
|
215 | :command:`ipcluster` when working with the cluster. | |
216 |
|
216 | |||
217 | Associated with each cluster profile is a cluster directory. This cluster |
|
217 | Associated with each cluster profile is a cluster directory. This cluster | |
218 | directory is a specially named directory (typically located in the |
|
218 | directory is a specially named directory (typically located in the | |
219 | :file:`.ipython` subdirectory of your home directory) that contains the |
|
219 | :file:`.ipython` subdirectory of your home directory) that contains the | |
220 | configuration files for a particular cluster profile, as well as log files and |
|
220 | configuration files for a particular cluster profile, as well as log files and | |
221 | security keys. The naming convention for cluster directories is: |
|
221 | security keys. The naming convention for cluster directories is: | |
222 | :file:`profile_<profile name>`. Thus, the cluster directory for a profile named |
|
222 | :file:`profile_<profile name>`. Thus, the cluster directory for a profile named | |
223 | "foo" would be :file:`.ipython\\cluster_foo`. |
|
223 | "foo" would be :file:`.ipython\\cluster_foo`. | |
224 |
|
224 | |||
225 | To create a new cluster profile (named "mycluster") and the associated cluster |
|
225 | To create a new cluster profile (named "mycluster") and the associated cluster | |
226 | directory, type the following command at the Windows Command Prompt:: |
|
226 | directory, type the following command at the Windows Command Prompt:: | |
227 |
|
227 | |||
228 | ipython profile create --parallel --profile=mycluster |
|
228 | ipython profile create --parallel --profile=mycluster | |
229 |
|
229 | |||
230 | The output of this command is shown in the screenshot below. Notice how |
|
230 | The output of this command is shown in the screenshot below. Notice how | |
231 | :command:`ipcluster` prints out the location of the newly created profile |
|
231 | :command:`ipcluster` prints out the location of the newly created profile | |
232 | directory:: |
|
232 | directory:: | |
233 |
|
233 | |||
234 | Z:\>ipython profile create mycluster --parallel |
|
234 | Z:\>ipython profile create mycluster --parallel | |
235 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipython_config.py' |
|
235 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipython_config.py' | |
236 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipcontroller_config.py' |
|
236 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipcontroller_config.py' | |
237 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipengine_config.py' |
|
237 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipengine_config.py' | |
238 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipcluster_config.py' |
|
238 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\ipcluster_config.py' | |
239 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\iplogger_config.py' |
|
239 | [ProfileCreate] Generating default config file: u'\\\\blue\\domainusers$\\bgranger\\.ipython\\profile_mycluster\\iplogger_config.py' | |
240 |
|
240 | |||
241 | Z:\> |
|
241 | Z:\> | |
242 |
|
242 | |||
243 | Configuring a cluster profile |
|
243 | Configuring a cluster profile | |
244 | ----------------------------- |
|
244 | ----------------------------- | |
245 |
|
245 | |||
246 | Next, you will need to configure the newly created cluster profile by editing |
|
246 | Next, you will need to configure the newly created cluster profile by editing | |
247 | the following configuration files in the cluster directory: |
|
247 | the following configuration files in the cluster directory: | |
248 |
|
248 | |||
249 | * :file:`ipcluster_config.py` |
|
249 | * :file:`ipcluster_config.py` | |
250 | * :file:`ipcontroller_config.py` |
|
250 | * :file:`ipcontroller_config.py` | |
251 | * :file:`ipengine_config.py` |
|
251 | * :file:`ipengine_config.py` | |
252 |
|
252 | |||
253 | When :command:`ipcluster` is run, these configuration files are used to |
|
253 | When :command:`ipcluster` is run, these configuration files are used to | |
254 | determine how the engines and controller will be started. In most cases, |
|
254 | determine how the engines and controller will be started. In most cases, | |
255 | you will only have to set a few of the attributes in these files. |
|
255 | you will only have to set a few of the attributes in these files. | |
256 |
|
256 | |||
257 | To configure :command:`ipcluster` to use the Windows HPC job scheduler, you |
|
257 | To configure :command:`ipcluster` to use the Windows HPC job scheduler, you | |
258 | will need to edit the following attributes in the file |
|
258 | will need to edit the following attributes in the file | |
259 | :file:`ipcluster_config.py`:: |
|
259 | :file:`ipcluster_config.py`:: | |
260 |
|
260 | |||
261 | # Set these at the top of the file to tell ipcluster to use the |
|
261 | # Set these at the top of the file to tell ipcluster to use the | |
262 | # Windows HPC job scheduler. |
|
262 | # Windows HPC job scheduler. | |
263 | c.IPClusterStart.controller_launcher_class = 'WindowsHPCControllerLauncher' |
|
263 | c.IPClusterStart.controller_launcher_class = 'WindowsHPCControllerLauncher' | |
264 | c.IPClusterEngines.engine_launcher_class = 'WindowsHPCEngineSetLauncher' |
|
264 | c.IPClusterEngines.engine_launcher_class = 'WindowsHPCEngineSetLauncher' | |
265 |
|
265 | |||
266 | # Set these to the host name of the scheduler (head node) of your cluster. |
|
266 | # Set these to the host name of the scheduler (head node) of your cluster. | |
267 | c.WindowsHPCControllerLauncher.scheduler = 'HEADNODE' |
|
267 | c.WindowsHPCControllerLauncher.scheduler = 'HEADNODE' | |
268 | c.WindowsHPCEngineSetLauncher.scheduler = 'HEADNODE' |
|
268 | c.WindowsHPCEngineSetLauncher.scheduler = 'HEADNODE' | |
269 |
|
269 | |||
270 | There are a number of other configuration attributes that can be set, but |
|
270 | There are a number of other configuration attributes that can be set, but | |
271 | in most cases these will be sufficient to get you started. |
|
271 | in most cases these will be sufficient to get you started. | |
272 |
|
272 | |||
273 | .. warning:: |
|
273 | .. warning:: | |
274 | If any of your configuration attributes involve specifying the location |
|
274 | If any of your configuration attributes involve specifying the location | |
275 | of shared directories or files, you must make sure that you use UNC paths |
|
275 | of shared directories or files, you must make sure that you use UNC paths | |
276 | like :file:`\\\\host\\share`. It is helpful to specify |
|
276 | like :file:`\\\\host\\share`. It is helpful to specify | |
277 | these paths using raw Python strings: ``r'\\host\share'`` to make sure |
|
277 | these paths using raw Python strings: ``r'\\host\share'`` to make sure | |
278 | that the backslashes are properly escaped. |
|
278 | that the backslashes are properly escaped. | |
279 |
|
279 | |||
280 | Starting the cluster profile |
|
280 | Starting the cluster profile | |
281 | ---------------------------- |
|
281 | ---------------------------- | |
282 |
|
282 | |||
283 | Once a cluster profile has been configured, starting an IPython cluster using |
|
283 | Once a cluster profile has been configured, starting an IPython cluster using | |
284 | the profile is simple:: |
|
284 | the profile is simple:: | |
285 |
|
285 | |||
286 | ipcluster start --profile=mycluster -n 32 |
|
286 | ipcluster start --profile=mycluster -n 32 | |
287 |
|
287 | |||
288 | The ``-n`` option tells :command:`ipcluster` how many engines to start (in |
|
288 | The ``-n`` option tells :command:`ipcluster` how many engines to start (in | |
289 | this case 32). Stopping the cluster is as simple as typing Control-C. |
|
289 | this case 32). Stopping the cluster is as simple as typing Control-C. | |
290 |
|
290 | |||
291 | Using the HPC Job Manager |
|
291 | Using the HPC Job Manager | |
292 | ------------------------- |
|
292 | ------------------------- | |
293 | fΓΈΓΈ |
|
293 | fΓΈΓΈ | |
294 | When ``ipcluster start`` is run the first time, :command:`ipcluster` creates |
|
294 | When ``ipcluster start`` is run the first time, :command:`ipcluster` creates | |
295 | two XML job description files in the cluster directory: |
|
295 | two XML job description files in the cluster directory: | |
296 |
|
296 | |||
297 | * :file:`ipcontroller_job.xml` |
|
297 | * :file:`ipcontroller_job.xml` | |
298 | * :file:`ipengineset_job.xml` |
|
298 | * :file:`ipengineset_job.xml` | |
299 |
|
299 | |||
300 | Once these files have been created, they can be imported into the HPC Job |
|
300 | Once these files have been created, they can be imported into the HPC Job | |
301 | Manager application. Then, the controller and engines for that profile can be |
|
301 | Manager application. Then, the controller and engines for that profile can be | |
302 | started using the HPC Job Manager directly, without using :command:`ipcluster`. |
|
302 | started using the HPC Job Manager directly, without using :command:`ipcluster`. | |
303 | However, anytime the cluster profile is re-configured, ``ipcluster start`` |
|
303 | However, anytime the cluster profile is re-configured, ``ipcluster start`` | |
304 | must be run again to regenerate the XML job description files. The |
|
304 | must be run again to regenerate the XML job description files. The | |
305 | following screenshot shows what the HPC Job Manager interface looks like |
|
305 | following screenshot shows what the HPC Job Manager interface looks like | |
306 | with a running IPython cluster. |
|
306 | with a running IPython cluster. | |
307 |
|
307 | |||
308 | .. image:: figs/hpc_job_manager.* |
|
308 | .. image:: figs/hpc_job_manager.* | |
309 |
|
309 | |||
310 | Performing a simple interactive parallel computation |
|
310 | Performing a simple interactive parallel computation | |
311 | ==================================================== |
|
311 | ==================================================== | |
312 |
|
312 | |||
313 | Once you have started your IPython cluster, you can start to use it. To do |
|
313 | Once you have started your IPython cluster, you can start to use it. To do | |
314 | this, open up a new Windows Command Prompt and start up IPython's interactive |
|
314 | this, open up a new Windows Command Prompt and start up IPython's interactive | |
315 | shell by typing:: |
|
315 | shell by typing:: | |
316 |
|
316 | |||
317 | ipython |
|
317 | ipython | |
318 |
|
318 | |||
319 | Then you can create a :class:`DirectView` instance for your profile and |
|
319 | Then you can create a :class:`DirectView` instance for your profile and | |
320 | use the resulting instance to do a simple interactive parallel computation. In |
|
320 | use the resulting instance to do a simple interactive parallel computation. In | |
321 | the code and screenshot that follows, we take a simple Python function and |
|
321 | the code and screenshot that follows, we take a simple Python function and | |
322 | apply it to each element of an array of integers in parallel using the |
|
322 | apply it to each element of an array of integers in parallel using the | |
323 | :meth:`DirectView.map` method: |
|
323 | :meth:`DirectView.map` method: | |
324 |
|
324 | |||
325 | .. sourcecode:: ipython |
|
325 | .. sourcecode:: ipython | |
326 |
|
326 | |||
327 | In [1]: from IPython.parallel import * |
|
327 | In [1]: from IPython.parallel import * | |
328 |
|
328 | |||
329 | In [2]: c = Client(profile='mycluster') |
|
329 | In [2]: c = Client(profile='mycluster') | |
330 |
|
330 | |||
331 | In [3]: view = c[:] |
|
331 | In [3]: view = c[:] | |
332 |
|
332 | |||
333 | In [4]: c.ids |
|
333 | In [4]: c.ids | |
334 | Out[4]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
|
334 | Out[4]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
335 |
|
335 | |||
336 | In [5]: def f(x): |
|
336 | In [5]: def f(x): | |
337 | ...: return x**10 |
|
337 | ...: return x**10 | |
338 |
|
338 | |||
339 | In [6]: view.map(f, range(15)) # f is applied in parallel |
|
339 | In [6]: view.map(f, range(15)) # f is applied in parallel | |
340 | Out[6]: |
|
340 | Out[6]: | |
341 | [0, |
|
341 | [0, | |
342 | 1, |
|
342 | 1, | |
343 | 1024, |
|
343 | 1024, | |
344 | 59049, |
|
344 | 59049, | |
345 | 1048576, |
|
345 | 1048576, | |
346 | 9765625, |
|
346 | 9765625, | |
347 | 60466176, |
|
347 | 60466176, | |
348 | 282475249, |
|
348 | 282475249, | |
349 | 1073741824, |
|
349 | 1073741824, | |
350 | 3486784401L, |
|
350 | 3486784401L, | |
351 | 10000000000L, |
|
351 | 10000000000L, | |
352 | 25937424601L, |
|
352 | 25937424601L, | |
353 | 61917364224L, |
|
353 | 61917364224L, | |
354 | 137858491849L, |
|
354 | 137858491849L, | |
355 | 289254654976L] |
|
355 | 289254654976L] | |
356 |
|
356 | |||
357 | The :meth:`map` method has the same signature as Python's builtin :func:`map` |
|
357 | The :meth:`map` method has the same signature as Python's builtin :func:`map` | |
358 | function, but runs the calculation in parallel. More involved examples of using |
|
358 | function, but runs the calculation in parallel. More involved examples of using | |
359 | :class:`DirectView` are provided in the examples that follow. |
|
359 | :class:`DirectView` are provided in the examples that follow. | |
360 |
|
360 |
General Comments 0
You need to be logged in to leave comments.
Login now