thinc icon indicating copy to clipboard operation
thinc copied to clipboard

[BUG] -- `numpy` 2.0.0 raises `ValueError` in `thinc.backends.numpy_ops`

Open it176131 opened this issue 1 year ago • 7 comments

How to reproduce the behaviour

Using Python 3.12.2 on a Windows 10 machine:

$ py -3.12 -m venv env $ source env/Scripts/activate $ pip install thinc -U $ python -c "from thinc.backends.numpy_ops import NumpyOps"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\user\test\env\Lib\site-packages\thinc\backends\__init__.py", line 17, in <module>
    from .cupy_ops import CupyOps
  File "C:\Users\user\test\env\Lib\site-packages\thinc\backends\cupy_ops.py", line 16, in <module>
    from .numpy_ops import NumpyOps
  File "thinc\backends\numpy_ops.pyx", line 1, in init thinc.backends.numpy_ops
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Your Environment

  • Operating System: Windows 10
  • Python Version Used: 3.12.2
  • Thinc Version Used: 9.0.0
  • Environment Information:
Package           Version
----------------- -------
annotated-types   0.7.0
blis              0.7.11
catalogue         2.0.10
colorama          0.4.6
confection        0.1.5
cymem             2.0.8
murmurhash        1.0.10
numpy             2.0.0
packaging         24.1
pip               24.0
preshed           3.0.9
pydantic          2.7.4
pydantic_core     2.18.4
setuptools        70.0.0
srsly             2.4.8
thinc             9.0.0
typing_extensions 4.12.2
wasabi            1.1.3

it176131 avatar Jun 17 '24 17:06 it176131

Figured I'd mention: I also experience this issue on Github Actions in CI running Linux.

https://github.com/koaning/arxiv-frontpage/actions/runs/9544267212/job/26302578156

koaning avatar Jun 17 '24 18:06 koaning

Figured I'd mention: I also experience this issue on Github Actions in CI running Linux.

https://github.com/koaning/arxiv-frontpage/actions/runs/9544267212/job/26302578156

That's how I first came across it as well, but on my company's CI so obv couldn't link to it 😅

it176131 avatar Jun 17 '24 18:06 it176131

Working on it

honnibal avatar Jun 18 '24 08:06 honnibal

I've been trying to get wheels built against numpy v2 for cython-blis but I'm having trouble with our wheel-building machinery.

I'm looking at just setting the upper pin for now instead.

honnibal avatar Jun 19 '24 12:06 honnibal

Just published a new version with the updated pin. This should fix the installation. I'll still work on getting Thinc built against numpy v2 though.

honnibal avatar Jun 19 '24 18:06 honnibal

Termux here. FYI, it used to work, see my other report here, now same:

File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/thinc/backends/cupy_ops.py", line 16, in <module>            from .numpy_ops import NumpyOps       
ModuleNotFoundError: No module named 'thinc.backends.numpy_ops'                     
~/downloads $

But with the older numpy:

~/downloads $ pip show numpy              
Name: numpy                               
Version: 1.26.4

(The newest 2.0 numpy installs too but it kvetches as below, only with tts, while the old one does not, so I have to use the older one:)

File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scipy/sparse/__init__.py", line 295, in <module>             from ._csr import *                     
File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/scipy/sparse/_csr.py", line 11, in <module>                  from ._sparsetools import (csr_tocsc, csr_tobsr, csr_count_blocks,              
ImportError: numpy.core.multiarray failed to import                                 ~/downloads $

Manamama avatar Jun 21 '24 00:06 Manamama

I believe this should be resolved now. Please reopen (or open a new issue) if there's continued problems.

Note that it's best to install into a clean environment for this sort of thing, as updated the environment in-place doesn't always work well.

honnibal avatar Jan 13 '25 12:01 honnibal