File: install.html

package info (click to toggle)
mpi4py 3.0.3-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,428 kB
  • sloc: python: 18,672; javascript: 9,118; ansic: 7,092; makefile: 567; sh: 183; f90: 158; cpp: 103
file content (312 lines) | stat: -rw-r--r-- 17,307 bytes parent folder | download
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Installation &#8212; MPI for Python 3.0.3 documentation</title>
    <link rel="stylesheet" href="_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/language_data.js"></script>
    
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Appendix" href="appendix.html" />
    <link rel="prev" title="Citation" href="citing.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="appendix.html" title="Appendix"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="citing.html" title="Citation"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">MPI for Python 3.0.3 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h1>
<div class="section" id="requirements">
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this headline">¶</a></h2>
<p>You need to have the following software properly installed in order to
build <em>MPI for Python</em>:</p>
<ul>
<li><p class="first">A working MPI implementation, preferably supporting MPI-3 and built
with shared/dynamic libraries.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you want to build some MPI implementation from sources,
check the instructions at <a class="reference internal" href="appendix.html#building-mpi"><span class="std std-ref">Building MPI from sources</span></a> in the appendix.</p>
</div>
</li>
<li><p class="first">Python 2.7, 3.3 or above.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Some MPI-1 implementations <strong>do require</strong> the actual
command line arguments to be passed in <code class="xref c c-func docutils literal notranslate"><span class="pre">MPI_Init()</span></code>. In
this case, you will need to use a rebuilt, MPI-enabled, Python
interpreter executable. <em>MPI for Python</em> has some support for
alleviating you from this task. Check the instructions at
<a class="reference internal" href="appendix.html#python-mpi"><span class="std std-ref">MPI-enabled Python interpreter</span></a> in the appendix.</p>
</div>
</li>
</ul>
</div>
<div class="section" id="using-pip-or-easy-install">
<h2>Using <strong>pip</strong> or <strong>easy_install</strong><a class="headerlink" href="#using-pip-or-easy-install" title="Permalink to this headline">¶</a></h2>
<p>If you already have a working MPI (either if you installed it from
sources or by using a pre-built package from your favourite GNU/Linux
distribution) and the <strong class="program">mpicc</strong> compiler wrapper is on your
search path, you can use <strong class="program">pip</strong>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ [sudo] pip install mpi4py
</pre></div>
</div>
<p>or alternatively <em>setuptools</em> <strong class="program">easy_install</strong> (deprecated):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ [sudo] easy_install mpi4py
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>If the <strong class="program">mpicc</strong> compiler wrapper is not on your
search path (or if it has a different name) you can use
<strong class="program">env</strong> to pass the environment variable <span class="target" id="index-0"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">MPICC</span></code>
providing the full path to the MPI compiler wrapper executable:</p>
<div class="last highlight-default notranslate"><div class="highlight"><pre><span></span>$ [sudo] env MPICC=/path/to/mpicc pip install mpi4py

$ [sudo] env MPICC=/path/to/mpicc easy_install mpi4py
</pre></div>
</div>
</div>
</div>
<div class="section" id="using-distutils">
<h2>Using <strong>distutils</strong><a class="headerlink" href="#using-distutils" title="Permalink to this headline">¶</a></h2>
<p>The <em>MPI for Python</em> package is available for download at the project
website generously hosted by Bitbucket. You can use <strong class="program">curl</strong>
or <strong class="program">wget</strong> to get a release tarball.</p>
<ul>
<li><p class="first">Using <strong class="program">curl</strong>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ curl -O https://bitbucket.org/mpi4py/mpi4py/downloads/mpi4py-X.Y.tar.gz
</pre></div>
</div>
</li>
<li><p class="first">Using <strong class="program">wget</strong>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ wget https://bitbucket.org/mpi4py/mpi4py/downloads/mpi4py-X.Y.tar.gz
</pre></div>
</div>
</li>
</ul>
<p>After unpacking the release tarball:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ tar -zxf mpi4py-X.Y.tar.gz
$ cd mpi4py-X.Y
</pre></div>
</div>
<p>the package is ready for building.</p>
<p><em>MPI for Python</em> uses a standard distutils-based build system. However,
some distutils commands (like <em>build</em>) have additional options:</p>
<dl class="cmdoption">
<dt id="cmdoption-mpicc">
<code class="descname">--mpicc</code><code class="descclassname">=</code><a class="headerlink" href="#cmdoption-mpicc" title="Permalink to this definition">¶</a></dt>
<dd><p>Lets you specify a special location or name for the
<strong class="program">mpicc</strong> compiler wrapper.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-mpi">
<code class="descname">--mpi</code><code class="descclassname">=</code><a class="headerlink" href="#cmdoption-mpi" title="Permalink to this definition">¶</a></dt>
<dd><p>Lets you pass a section with MPI configuration within a special
configuration file.</p>
</dd></dl>

<dl class="cmdoption">
<dt id="cmdoption-configure">
<code class="descname">--configure</code><code class="descclassname"></code><a class="headerlink" href="#cmdoption-configure" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs exhaustive tests for checking about missing MPI types,
constants, and functions. This option should be passed in order to
build <em>MPI for Python</em> against old MPI-1 or MPI-2 implementations,
possibly providing a subset of MPI-3.</p>
</dd></dl>

<p>If you use a MPI implementation providing a <strong class="program">mpicc</strong> compiler
wrapper (e.g., MPICH, Open MPI), it will be used for compilation and
linking. This is the preferred and easiest way of building <em>MPI for
Python</em>.</p>
<p>If <strong class="program">mpicc</strong> is located somewhere in your search path, simply
run the <em>build</em> command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python setup.py build
</pre></div>
</div>
<p>If <strong class="program">mpicc</strong> is not in your search path or the compiler wrapper
has a different name, you can run the <em>build</em> command specifying its
location:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python setup.py build --mpicc=/where/you/have/mpicc
</pre></div>
</div>
<p>Alternatively, you can provide all the relevant information about your
MPI implementation by editing the file called <code class="file docutils literal notranslate"><span class="pre">mpi.cfg</span></code>. You can
use the default section <code class="docutils literal notranslate"><span class="pre">[mpi]</span></code> or add a new, custom section, for
example <code class="docutils literal notranslate"><span class="pre">[other_mpi]</span></code> (see the examples provided in the
<code class="file docutils literal notranslate"><span class="pre">mpi.cfg</span></code> file as a starting point to write your own section):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">mpi</span><span class="p">]</span>

<span class="n">include_dirs</span>         <span class="o">=</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">mpi</span><span class="o">/</span><span class="n">include</span>
<span class="n">libraries</span>            <span class="o">=</span> <span class="n">mpi</span>
<span class="n">library_dirs</span>         <span class="o">=</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">mpi</span><span class="o">/</span><span class="n">lib</span>
<span class="n">runtime_library_dirs</span> <span class="o">=</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">mpi</span><span class="o">/</span><span class="n">lib</span>

<span class="p">[</span><span class="n">other_mpi</span><span class="p">]</span>

<span class="n">include_dirs</span>         <span class="o">=</span> <span class="o">/</span><span class="n">opt</span><span class="o">/</span><span class="n">mpi</span><span class="o">/</span><span class="n">include</span> <span class="o">...</span>
<span class="n">libraries</span>            <span class="o">=</span> <span class="n">mpi</span> <span class="o">...</span>
<span class="n">library_dirs</span>         <span class="o">=</span> <span class="o">/</span><span class="n">opt</span><span class="o">/</span><span class="n">mpi</span><span class="o">/</span><span class="n">lib</span> <span class="o">...</span>
<span class="n">runtime_library_dirs</span> <span class="o">=</span> <span class="o">/</span><span class="n">op</span><span class="o">/</span><span class="n">mpi</span><span class="o">/</span><span class="n">lib</span> <span class="o">...</span>

<span class="o">...</span>
</pre></div>
</div>
<p>and then run the <em>build</em> command, perhaps specifying you custom
configuration section:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python setup.py build --mpi=other_mpi
</pre></div>
</div>
<p>After building, the package is ready for install.</p>
<p>If you have root privileges (either by log-in as the root user of by
using <strong class="command">sudo</strong>) and you want to install <em>MPI for Python</em> in
your system for all users, just do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python setup.py install
</pre></div>
</div>
<p>The previous steps will install the <code class="xref py py-mod docutils literal notranslate"><span class="pre">mpi4py</span></code> package at standard
location <code class="file docutils literal notranslate"><em><span class="pre">prefix</span></em><span class="pre">/lib/python</span><em><span class="pre">X</span></em><span class="pre">.</span><em><span class="pre">X</span></em><span class="pre">/site-packages</span></code>.</p>
<p>If you do not have root privileges or you want to install <em>MPI for
Python</em> for your private use, just do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python setup.py install --user
</pre></div>
</div>
</div>
<div class="section" id="testing">
<h2>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h2>
<p>To quickly test the installation:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mpiexec -n 5 python -m mpi4py.bench helloworld
Hello, World! I am process 0 of 5 on localhost.
Hello, World! I am process 1 of 5 on localhost.
Hello, World! I am process 2 of 5 on localhost.
Hello, World! I am process 3 of 5 on localhost.
Hello, World! I am process 4 of 5 on localhost.
</pre></div>
</div>
<p>If you installed from source, issuing at the command line:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mpiexec -n 5 python demo/helloworld.py
</pre></div>
</div>
<p>or (in the case of ancient MPI-1 implementations):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mpirun -np 5 python `pwd`/demo/helloworld.py
</pre></div>
</div>
<p>will launch a five-process run of the Python interpreter and run the
test script <code class="file docutils literal notranslate"><span class="pre">demo/helloworld.py</span></code> from the source distribution.</p>
<p>You can also run all the <em>unittest</em> scripts:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mpiexec -n 5 python test/runtests.py
</pre></div>
</div>
<p>or, if you have <a class="reference external" href="http://nose.readthedocs.io/">nose</a> unit testing framework installed:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mpiexec -n 5 nosetests -w test
</pre></div>
</div>
<p>or, if you have <a class="reference external" href="http://docs.pytest.org/">py.test</a> unit testing framework installed:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ mpiexec -n 5 py.test test/
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Installation</a><ul>
<li><a class="reference internal" href="#requirements">Requirements</a></li>
<li><a class="reference internal" href="#using-pip-or-easy-install">Using <strong>pip</strong> or <strong>easy_install</strong></a></li>
<li><a class="reference internal" href="#using-distutils">Using <strong>distutils</strong></a></li>
<li><a class="reference internal" href="#testing">Testing</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="citing.html"
                        title="previous chapter">Citation</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="appendix.html"
                        title="next chapter">Appendix</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/install.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="appendix.html" title="Appendix"
             >next</a> |</li>
        <li class="right" >
          <a href="citing.html" title="Citation"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">MPI for Python 3.0.3 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2019, Lisandro Dalcin.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.4.
    </div>
  </body>
</html>