-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.mac
93 lines (70 loc) · 2.88 KB
/
README.mac
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
======================== Recipe 2 : using anaconda =========================
# install packages using macports
sudo port install openmpi
# activate what we have just installed (mandatory)
sudo port select mpi openmpi-mp-fortran
# my anaconda is in my $HOME - no need for sudo
pip install mpi4py
conda install netcdf4
compile the remap library
run the remap.py script
==================== Checking which libraries are loaded ======================
Useful to make sure that mpirun, remap and python use the same MPI library.
sudo dtruss -f -t open sudo -u $(whoami) mpirun -np 1 python test.py 2>out
grep mpich out
grep openmpi out
where test.py contains
from mpi4py import MPI
import netCDF4
import ctypes as ct
import os
test = ct.cdll.LoadLibrary(os.path.realpath('libmapper.so'))
If grep finds both mpich and openmpi, something is wrong !
====================== Various ways to mess up python/netCDF/MPI on MacOS ====================
Anaconda vs macports python
===========================
I have several pythons installed : 3 from Apple, one from macports and one from the Anaconda distribution, which is the default on my path.
* find whether we use python from MacPorts or anaconda
which python
the one from macports is in /opt/local/bin
* check active macports python version
port select python
(mine : python27)
* if desired, set the path to avoid anaconda
echo $PATH
result : /Users/dubos/anaconda/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
Below, [with macports] assumes that « which python » finds /opt/local/bin/python » while [with anaconda] assumes it finds the anaconda-provided python.
Python-netCDF
=============
[with macports] :
sudo port install py-netcdf4
[with anaconda] :
conda install netcdf4
Notice that this will also compile its own instance of netCDF.
Notice that in principle one could install python-netcdf using pip or easy_install. In my case it fails - there is a version mismatch for the HDF library at runtime
MPI
===
Macports can install openmpi, mpich or both (I have both). If both are installed one is activated by « port select ».
It will install it for a specific compiler.
* checking your active compiler
port select gcc
* installing openmpi
sudo port install openmpi
* checking for which gcc openmpi has been compiled
port installed openmpi-default
* checking your active mpi
port select mpi
* selecting openmpi (for example)
sudo port select mpi openmpi-mp-fortran
MPI4py
======
It is important to compile the mapper library with the same MPI as mpi4py !
easy_install fails on my Mac so I must use pip
[with MacPorts] :
sudo port install py-pip
sudo port select pip pip27
sudo pip install mpi4py
[with anaconda] : pip is already installed,
which pip
pip install mpi4py