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

Help needed with building libraries #213

Closed jovian-explorer closed 2 years ago

jovian-explorer commented 2 years ago

This is what is happening when I try cmake ..

(petitRADTRANS) keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest/MultiNest/build$ cmake ..
-- The Fortran compiler identification is GNU 9.4.0
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working Fortran compiler: /usr/bin/f95
-- Check for working Fortran compiler: /usr/bin/f95  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/f95 supports Fortran 90
-- Checking whether /usr/bin/f95 supports Fortran 90 -- yes
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindBLAS.cmake:810 (find_package_handle_standard_args)
  /usr/share/cmake-3.16/Modules/FindLAPACK.cmake:197 (find_package)
  src/CMakeLists.txt:31 (FIND_PACKAGE)

-- Configuring incomplete, errors occurred!
See also "/home/keshav/petitRADTRANS/petitRADTRANS/PyMultiNest/MultiNest/build/CMakeFiles/CMakeOutput.log".
See also "/home/keshav/petitRADTRANS/petitRADTRANS/PyMultiNest/MultiNest/build/CMakeFiles/CMakeError.log".
jovian-explorer commented 2 years ago

I am using python 3.9.7 on ubuntu 20.0.4. I am currently trying to do retrievals using petitRADTRANS which uses Pymultinest. I am also copy pasting conda list just in case this helps.

(petitRADTRANS) keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ conda list
# packages in environment at /home/keshav/miniconda3/envs/petitRADTRANS:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
astropy                   5.0.4                    pypi_0    pypi
ca-certificates           2022.4.26            h06a4308_0  
certifi                   2022.5.18.1      py39h06a4308_0  
corner                    2.2.1                    pypi_0    pypi
cycler                    0.11.0                   pypi_0    pypi
emcee                     3.1.2                    pypi_0    pypi
exo-k                     1.1.1                    pypi_0    pypi
fonttools                 4.33.3                   pypi_0    pypi
h5py                      3.6.0                    pypi_0    pypi
kiwisolver                1.4.2                    pypi_0    pypi
ld_impl_linux-64          2.38                 h1181459_1  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 11.2.0               h1234567_0  
libgomp                   11.2.0               h1234567_0  
libstdcxx-ng              11.2.0               h1234567_0  
llvmlite                  0.38.1                   pypi_0    pypi
matplotlib                3.5.2                    pypi_0    pypi
molmass                   2021.6.18                pypi_0    pypi
ncurses                   6.3                  h7f8727e_2  
numba                     0.55.1                   pypi_0    pypi
numpy                     1.22.4                   pypi_0    pypi
openssl                   1.1.1o               h7f8727e_0  
packaging                 21.3                     pypi_0    pypi
pandas                    1.4.2                    pypi_0    pypi
petitradtrans             2.4.2                    pypi_0    pypi
pillow                    9.1.1                    pypi_0    pypi
pip                       21.2.4           py39h06a4308_0  
pyerfa                    2.0.0.1                  pypi_0    pypi
pymultinest               2.11                     pypi_0    pypi
pyparsing                 3.0.9                    pypi_0    pypi
python                    3.9.7                h12debd9_1  
python-dateutil           2.8.2                    pypi_0    pypi
pytz                      2022.1                   pypi_0    pypi
pyyaml                    6.0                      pypi_0    pypi
readline                  8.1.2                h7f8727e_1  
scipy                     1.8.1                    pypi_0    pypi
seaborn                   0.11.2                   pypi_0    pypi
setuptools                61.2.0           py39h06a4308_0  
six                       1.16.0                   pypi_0    pypi
sqlite                    3.38.3               hc218d9a_0  
tk                        8.6.11               h1ccaba5_1  
tzdata                    2022a                hda174b7_0  
wheel                     0.37.1             pyhd3eb1b0_0  
xz                        5.2.5                h7f8727e_1  
zlib                      1.2.12               h7f8727e_2
jovian-explorer commented 2 years ago

Further attempts have led me here -

keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ echo 'export LD_LIBRARY_PATH="home/keshav/petitRADTRANS/petitRADTRANS/PyMultiNest/MultiNest/lib"' >>~/.bashrc
keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ python3 -c 'import pycuba'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/keshav/petitRADTRANS/petitRADTRANS/PyMultiNest/pycuba/__init__.py", line 12, in <module>
    lib = ctypes.cdll.LoadLibrary('libcuba.so')
  File "/usr/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcuba.so: cannot open shared object file: No such file or directory
keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ python3 -c 'import pymultinest'

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

ERROR:   Could not load MultiNest library: libmultinest.so
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

problem: libmultinest.so: cannot open shared object file: No such file or directory
jovian-explorer commented 2 years ago

Just now, I think I have managed to sort out the issue.

(petitRADTRANS) keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ export LD_LIBRARY_PATH=/home/keshav/petitRADTRANS/petitRADTRANS/MultiNest/lib:/home/keshav/petitRADTRANS/petitRADTRANS/PyMultiNest/cuba:$LD_LIBRARY_PATH
(petitRADTRANS) keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ python -c 'import pymultinest'
(petitRADTRANS) keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ python3 -c 'import pycuba'

I am still keeping this issue open just in case for the time being.

jovian-explorer commented 2 years ago

On using the command

(petitRADTRANS) keshav@dev:~/petitRADTRANS/petitRADTRANS/PyMultiNest$ python3 pymultinest_demo.py

I get

Acceptance Rate:                        0.672192
Replacements:                               3650
Total Samples:                              5430
Nested Sampling ln(Z):                235.333071
Importance Nested Sampling ln(Z):     235.927906 +/-  0.062817
Acceptance Rate:                        0.672238
Replacements:                               3700
Total Samples:                              5504
Nested Sampling ln(Z):                235.383087
Importance Nested Sampling ln(Z):     235.930051 +/-  0.062592
Acceptance Rate:                        0.671178
Replacements:                               3719
Total Samples:                              5541
Nested Sampling ln(Z):                235.400517
Importance Nested Sampling ln(Z):     235.930067 +/-  0.062549
 ln(ev)=   235.75232283539211      +/-  0.12532255032893436     
 Total Likelihood Evaluations:         5541
 Sampling finished. Exiting MultiNest
  analysing data from chains/3-.txt

evidence: 235.8 +- 0.1

parameter values:
              x : 15.111 +- 8.616
              y : 17.870 +- 8.871
jovian-explorer commented 2 years ago

I think I have managed to solve it. Was fun!!