JohannesBuchner / PyMultiNest

Pythonic Bayesian inference and visualization for the MultiNest Nested Sampling Algorithm and PyCuba's cubature algorithms.
http://johannesbuchner.github.io/PyMultiNest/
Other
194 stars 88 forks source link

Possible Issue with Mac M1 Chip #214

Open haileymoore opened 2 years ago

haileymoore commented 2 years ago

I am attempting to install MultiNest on my Mac running MacOS Monterey 12.5.1. I am able to run cmake, but I do get a few warnings near the end, notably about missing MPI. I'm planning on running it locally, so I'm not sure if the MPI libraries are necessary or if I can get away with building only non-MPI libraries. At the end of cmake, I get these warnings:

-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS) 
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS) 
-- Could NOT find MPI_Fortran (missing: MPI_Fortran_LIB_NAMES MPI_Fortran_F77_HEADER_DIR MPI_Fortran_MODULE_DIR MPI_Fortran_WORKS) 
-- Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND MPI_Fortran_FOUND) 
-- MPI not found, only non-MPI MultiNest libraries will be built.

Given that this runs, I then tried to run make, where I get this error:

ld: warning: ignoring file /Users/Hailey/MultiNest/lib/libmultinest.3.10.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /Users/Hailey/opt/anaconda3/envs/isochrones/lib/libblas.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "___nested_MOD_nestrun", referenced from:
      _run in eggbox.c.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [/Users/Hailey/MultiNest/bin/eggboxC] Error 1
make[1]: *** [src/example_eggbox_C/CMakeFiles/eggboxC.dir/all] Error 2
make: *** [all] Error 2

From what I can tell, this looks like an error due to make looking for an Intel chip rather than the Mac M1 silicon chip. Is there a work around for installation, perhaps anything to add in the building stage to help with this issue?

JohannesBuchner commented 2 years ago

MPI is not necessary if you do not want to run parallelized.

JohannesBuchner commented 2 years ago

This seems to be caused by mixing libraries that are compiled for macOS-arm64 vs macOS-x86_64.

https://github.com/confluentinc/confluent-kafka-go/issues/591 https://stackoverflow.com/questions/65798262/building-for-macos-x86-64-but-attempting-to-link-with-file-built-for-macos-arm64 https://developer.apple.com/forums/thread/694062

DavidMoiseNataf commented 1 year ago

I had the same problems on my M1. I did find a solution to the MPI issue.

For the other issue, I think it's because, as written above, that there are multiple compilers on the system that compete for attention, and they need to be prioritized correctly in the $PATH for Multinest to be installed.

My get around is that I temporarily removed this anaconda-related text from my .bash_profile prior to installing multinest, and then re-inserted after installing multinest:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/davidnataf/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/davidnataf/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/davidnataf/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/davidnataf/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

So if I understand correctly, it's some of the Conda-related software which is interfering with the application of make on multinest. Note that I used the latest version of Anaconda, which is supposed to support M1 architecture.