-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL.txt
168 lines (115 loc) · 5.45 KB
/
INSTALL.txt
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
.. -*- rest -*-
.. vim:syntax=rest
.. NB! Keep this document a valid restructured document.
Building and installing NumPy
+++++++++++++++++++++++++++++
:Authors: Numpy Developers <[email protected]>
:Discussions to: [email protected]
**IMPORTANT**: the below notes are about building Numpy, which for most users
is *not* the recommended way to install Numpy. Instead, use either a complete
scientific Python distribution or a binary installer - see
http://scipy.org/install.html.
.. Contents::
PREREQUISITES
=============
Building NumPy requires the following software installed:
1) For Python 2, Python__ 2.6.x or newer.
For Python 3, Python__ 3.2.x or newer.
On Debian and derivative (Ubuntu): python python-dev
On Windows: the official python installer on Python__ is enough
Make sure that the Python package distutils is installed before
continuing. For example, in Debian GNU/Linux, distutils is included
in the python-dev package.
Python must also be compiled with the zlib module enabled.
2) nose__ (optional) 1.0 or later
This is required for testing numpy, but not for using it.
Python__ http://www.python.org
nose__ http://somethingaboutorange.com/mrl/projects/nose/
Basic Installation
==================
To install numpy run:
python setup.py build -j 4 install --prefix $HOME/.local
This will compile numpy on 4 CPUs and install it into the specified prefix.
To perform an inplace build that can be run from the source folder run:
python setup.py build_ext --inplace -j 4
The number of build jobs can also be specified via the environment variable
NPY_NUM_BUILD_JOBS.
Fortran ABI mismatch
====================
The two most popular open source fortran compilers are g77 and gfortran.
Unfortunately, they are not ABI compatible, which means that concretely you
should avoid mixing libraries built with one with another. In particular,
if your blas/lapack/atlas is built with g77, you *must* use g77 when
building numpy and scipy; on the contrary, if your atlas is built with
gfortran, you *must* build numpy/scipy with gfortran.
Choosing the fortran compiler
-----------------------------
To build with g77:
python setup.py build --fcompiler=gnu
To build with gfortran:
python setup.py build --fcompiler=gnu95
How to check the ABI of blas/lapack/atlas
-----------------------------------------
One relatively simple and reliable way to check for the compiler used to
build a library is to use ldd on the library. If libg2c.so is a dependency,
this means that g77 has been used. If libgfortran.so is a dependency,
gfortran has been used. If both are dependencies, this means both have been
used, which is almost always a very bad idea.
Building with optimized BLAS support
====================================
Ubuntu/Debian
-------------
In order to build with optimized a BLAS providing development package must be installed.
Options are for example:
- libblas-dev
reference BLAS not very optimized
- libatlas-base-dev
generic tuned ATLAS, it is recommended to tune it to the available hardware,
see /usr/share/doc/libatlas3-base/README.Debian for instructions
- libopenblas-base
fast and runtime detected so no tuning required but as of version 2.11 still
suffers from correctness issues on some CPUs, test your applications
thoughly.
The actual implementation can be exchanged also after installation via the
alternatives mechanism:
update-alternatives --config libblas.so.3
update-alternatives --config liblapack.so.3
Or by preloading a specific BLAS library with
LD_PRELOAD=/usr/lib/atlas-base/atlas/libblas.so.3 python ...
Windows 32 bits notes
=====================
The MinGW compilers used to build the official Numpy binary installers for
32-bit Python on Windows can be found in https://github.com/numpy/numpy-vendor.
That repo also contains pre-built ATLAS binarues. The command to build and
install Numpy is:
$ python setup.py config --compiler=mingw32 build --compiler=mingw32 install
Typically, one needs to use a site.cfg file that looks like:
[atlas]
library_dirs = C:\local\lib\atlas
include_dirs = C:\local\lib\atlas
Windows 64 bits notes
=====================
Note: only AMD64 is supported (IA64 is not) - AMD64 is the version most
people want.
Free compilers (mingw-w64)
--------------------------
http://mingw-w64.sourceforge.net/
To use the free compilers (mingw-w64), you need to build your own
toolchain, as the mingw project only distribute cross-compilers
(cross-compilation is not supported by numpy). Since this toolchain is
still being worked on, serious compiler bugs can be expected. binutil 2.19
+ gcc 4.3.3 + mingw-w64 runtime gives you a working C compiler (but the C++
is broken). gcc 4.4 will hopefully be able to run natively.
This is the only tested way to get a numpy with a FULL blas/lapack (scipy
does not work because of C++).
MS compilers
------------
If you are familiar with MS tools, that's obviously the easiest path, and
the compilers are hopefully more mature (although in my experience, they
are quite fragile, and often segfault on invalid C code). The main drawback
is that mingw-w64 gfortran + MSVC does not work at all (it is unclear
whether it ever will). MSVC + ifort + MKL does work.
For python 2.6, you need VS 2008. The freely available version does not
contains 64 bits compilers (you also need the PSDK, v6.1).
It is crucial to use the right MS compiler version. For python 2.6, you
must use version 15. You can check the compiler version with cl.exe /?.