README.mac 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ======================== Recipe 2 : using anaconda =========================
  2. # install packages using macports
  3. sudo port install openmpi
  4. # activate what we have just installed (mandatory)
  5. sudo port select mpi openmpi-mp-fortran
  6. # my anaconda is in my $HOME - no need for sudo
  7. pip install mpi4py
  8. conda install netcdf4
  9. compile the remap library
  10. run the remap.py script
  11. ==================== Checking which libraries are loaded ======================
  12. Useful to make sure that mpirun, remap and python use the same MPI library.
  13. sudo dtruss -f -t open sudo -u $(whoami) mpirun -np 1 python test.py 2>out
  14. grep mpich out
  15. grep openmpi out
  16. where test.py contains
  17. from mpi4py import MPI
  18. import netCDF4
  19. import ctypes as ct
  20. import os
  21. test = ct.cdll.LoadLibrary(os.path.realpath('libmapper.so'))
  22. If grep finds both mpich and openmpi, something is wrong !
  23. ====================== Various ways to mess up python/netCDF/MPI on MacOS ====================
  24. Anaconda vs macports python
  25. ===========================
  26. I have several pythons installed : 3 from Apple, one from macports and one from the Anaconda distribution, which is the default on my path.
  27. * find whether we use python from MacPorts or anaconda
  28. which python
  29. the one from macports is in /opt/local/bin
  30. * check active macports python version
  31. port select python
  32. (mine : python27)
  33. * if desired, set the path to avoid anaconda
  34. echo $PATH
  35. 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
  36. export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin
  37. Below, [with macports] assumes that « which python » finds /opt/local/bin/python » while [with anaconda] assumes it finds the anaconda-provided python.
  38. Python-netCDF
  39. =============
  40. [with macports] :
  41. sudo port install py-netcdf4
  42. [with anaconda] :
  43. conda install netcdf4
  44. Notice that this will also compile its own instance of netCDF.
  45. 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
  46. MPI
  47. ===
  48. Macports can install openmpi, mpich or both (I have both). If both are installed one is activated by « port select ».
  49. It will install it for a specific compiler.
  50. * checking your active compiler
  51. port select gcc
  52. * installing openmpi
  53. sudo port install openmpi
  54. * checking for which gcc openmpi has been compiled
  55. port installed openmpi-default
  56. * checking your active mpi
  57. port select mpi
  58. * selecting openmpi (for example)
  59. sudo port select mpi openmpi-mp-fortran
  60. MPI4py
  61. ======
  62. It is important to compile the mapper library with the same MPI as mpi4py !
  63. easy_install fails on my Mac so I must use pip
  64. [with MacPorts] :
  65. sudo port install py-pip
  66. sudo port select pip pip27
  67. sudo pip install mpi4py
  68. [with anaconda] : pip is already installed,
  69. which pip
  70. pip install mpi4py