Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peptdeep 1.2.1 not compatible with numpy 2.0.1 #190

Open
xgwang-uw opened this issue Jul 25, 2024 · 2 comments
Open

peptdeep 1.2.1 not compatible with numpy 2.0.1 #190

xgwang-uw opened this issue Jul 25, 2024 · 2 comments

Comments

@xgwang-uw
Copy link

xgwang-uw commented Jul 25, 2024

Description
peptdeep library command failing with error:

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

....

Traceback (most recent call last):
  File "multiprocessing\pool.py", line 125, in worker
  File "C:\Users\Jason\workspaces\pwiz\pwiz_tools\Skyline\bin\x64\Debug\Tools\Python\3.12.4\alphapeptdeep\Lib\site-packages\peptdeep\pretrained_models.py", line 936, in _predict_func_for_mp
    return self.predict_all(
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\Jason\workspaces\pwiz\pwiz_tools\Skyline\bin\x64\Debug\Tools\Python\3.12.4\alphapeptdeep\Lib\site-packages\peptdeep\pretrained_models.py", line 1112, in predict_all
    self.predict_rt(precursor_df,
  File "C:\Users\Jason\workspaces\pwiz\pwiz_tools\Skyline\bin\x64\Debug\Tools\Python\3.12.4\alphapeptdeep\Lib\site-packages\peptdeep\pretrained_models.py", line 898, in predict_rt
    df = self.rt_model.predict(precursor_df,
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jason\workspaces\pwiz\pwiz_tools\Skyline\bin\x64\Debug\Tools\Python\3.12.4\alphapeptdeep\Lib\site-packages\peptdeep\model\model_interface.py", line 548, in predict
    predicts = self._predict_one_batch(*features)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jason\workspaces\pwiz\pwiz_tools\Skyline\bin\x64\Debug\Tools\Python\3.12.4\alphapeptdeep\Lib\site-packages\peptdeep\model\model_interface.py", line 855, in _predict_one_batch
    ).cpu().detach().numpy()
                     ^^^^^^^
RuntimeError: Numpy is not available

To Reproduce
Steps to reproduce the behavior:

  1. In terminal, run pip install peptdeep
  2. With a prepared alphapeptdeep settings.yaml file, run <path-to>\peptdeep.exe library <path-to>\settings.yaml

Workaround
Downgrading numpy to 1.26.4 gets rid of this issue. This can be considered a workaround.

Expected behavior
Successfully predict a spectral library and output a predict.speclib.hdf file.

Logs
peptdeep_library.log

Version (please complete the following information):

  • Installation Type: pip install peptdeep and pip install peptdeep[stable] has the same issue
  • Platform information
    • system Windows11
    • processor AMD x64
    • Python information:
      • peptdeep version: 1.2.1
      • numpy version: 2.0.1
      • torch: 2.4.0

Additional context
This issue is due to a known pytorch and numpy compatability issue: pytorch/pytorch#107302. Specifically, the .numpy() method stopped working in pytorch (for numpy 2.0).

Although the issue claimed to have the numpy backward compatibility added after pytorch 2.2, and the issue is already closed, there are still reports of the same issue very recently (eg1, eg2). Plus there is a similar issue still open with the same failure in Windows (eg3).

As we wait for the pytorch fix, I suggest to add numpy < 2.0 to the requirement.txt file, to bake the workaround into the stable version of peptdeep package, so that users don't experience the error with the peptdeep CLI.

@jalew188
Copy link
Collaborator

jalew188 commented Aug 5, 2024

Yes, this is because some of dependent packages are not compiled by numpy2 yet. I have add numpy<2 in the requirement.txt in the latest development branch

@jalew188
Copy link
Collaborator

jalew188 commented Aug 6, 2024

Tested on #193, fixed by the stable installation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants