JohannesBuchner / PyMultiNest

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

Can't find MPI libraries #224

Closed jenniferyee closed 1 year ago

jenniferyee commented 2 years ago

When I try to run MultiNest with MPI, I get the following error:

problem: libmpi_usempi.so.40: cannot open shared object file: No such file or d\ irectory

ERROR: Could not load MultiNest library: libmpi_usempi.so.40 ERROR: You have to build MultiNest, ERROR: and point the LD_LIBRARY_PATH environment variable to it! ERROR: manual: http://johannesbuchner.github.com/PyMultiNest/install.html

In reviewing my install logs from make, I find that MultiNest successfully found libmpi_usempi.so (no .40), and there were no other errors.

Where in the MultiNest code does it call libmpi_usempi.so.40 and is it a problem if I just change this to libmpi_usempi.so? More generally, how to I control the paths that MultiNest uses to look for external libraries?

JohannesBuchner commented 2 years ago

Try rebuilding Multinest from scratch and make sure you have a MPI compiler (mpifortran). The compiler / environment used by cmake/make must be consistent with the environment you run with.

JohannesBuchner commented 2 years ago

the linker assigns paths, and ldd can list them.

jenniferyee commented 2 years ago

Rebuilding from scratch didn't work. I am guessing that the error is a hard-coded bug looking for some specific version of libmpi_usempi. But I can't figure out what part of the code produces this error message. As far as I can tell, it comes from the a call to run._load_library(), but the only instances I can find that invokes this method are at Line 52 and 58, which check for 'libmultinest' and 'libmulitnest_mpi', respectively, NOT 'libmpi_usempi'.

JohannesBuchner commented 2 years ago

See https://github.com/JohannesBuchner/PyMultiNest/issues/223 for how to rebuild (read also the readme in build/) and build verbosely.

There is no hard-coded path. You may want to read up on linkers and dynamic libraries for understanding how to interpret ldd outputs. https://www.howtoforge.com/linux-ldd-command/

JohannesBuchner commented 2 years ago

https://en.wikipedia.org/wiki/Linker_(computing)

jenniferyee commented 2 years ago

This was indeed a problem with the path to my fortran libraries in my linker. Because this was not a problem with the MultiNest build or path (as stated in the error message), I suggest changing the error message to something like:

ERROR: Could not load MultiNest library dependency: libmpi_usempi.so.40 ERROR: Make sure that the LD_LIBRARY_PATH environment variable ERROR: includes the path to both MultiNest and your fortran libraries. ERROR: Use "ldd" on libmultinest_mpi.so to check that all dependent libraries ERROR: are properly linked.

jenniferyee commented 1 year ago

This was, indeed, a problem with my LD_LIBRARY_PATH.