adrn / thejoker

A custom Monte Carlo sampler for the (gravitational) two-body problem
MIT License
30 stars 8 forks source link

Numpy dependency causing errors on linux #135

Closed stephtdouglas closed 3 months ago

stephtdouglas commented 5 months ago

My student and I ran into some issues installing TheJoker on our HPC cluster. When installing on Python 3.10 or above, we get the following output

Collecting thejoker
  Using cached thejoker-1.3.0.tar.gz (2.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/home/douglste-laf/.conda/envs/newjoker/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/douglste-laf/.conda/envs/newjoker/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/douglste-laf/.conda/envs/newjoker/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-kot7ogin/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/tmp/pip-build-env-kot7ogin/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-kot7ogin/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 11, in <module>
        File "/tmp/pip-build-env-kot7ogin/overlay/lib/python3.10/site-packages/twobody/__init__.py", line 28, in <module>
          from .anomaly import *
        File "/tmp/pip-build-env-kot7ogin/overlay/lib/python3.10/site-packages/twobody/anomaly.py", line 9, in <module>
          from .wrap import (cy_mean_anomaly_from_eccentric_anomaly,
        File "twobody/wrap.pyx", line 1, in init twobody.wrap
      ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

It looks like this is a Numpy error, though they also blame pip. Resolving it requires using an older version of Numpy, none of which are compatible with Python>=3.10

I was able to solve this by requiring python=3.9 and numpy==1.26.4 when I created my conda environment. This is the full set of commands I used to get a working installation

conda create -n thejoker python=3.9 scipy==1.10 numpy==1.26.4
conda activate thejoker
conda install -c anaconda gcc
conda install h5py netCDF4
pip install thejoker

The cluster is running Rocky Linux (I believe Version 8) on an x86 64bit architecture. Unfortunately the documentation is a bit out of date at the moment, so I can't be 100% sure, but I've seen other packages running into the same error.

adrn commented 3 months ago

Sorry for the slowness and thanks for reporting! I just released a new version that I think should resolve the numpy compatibility issues related to their 2.0 release. You have a working install, so I understand if you don't want to test, but if you feel like making a new environment without the constraints above, can you see if it all works now?

stephtdouglas commented 3 months ago

I was successfully able to install thejoker with no errors, but it installed numpy=1.26.4 along the way, instead of numpy=2.1.0. When I tried installing in an environment that already had numpy=2.1.0, in uninstalled numpy and reverted it to the older version.

adrn commented 3 months ago

OK good -- thanks for checking!

Yes unfortunately this is expected: the current need for numpy<2 comes from pytensor (core dep of pymc), which requires numpy<2. But now things are set up so when that when pytensor is updated, thejoker should work seamlessly on numpy>=2.0.

adrn commented 3 months ago

I'm going to close this for now, but if anything else comes up feel free to re-open or make a new issue. Thanks again for reporting!