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

numpy v2.0.2 fail: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject #28

Open
rjurney opened this issue Jan 31, 2025 · 0 comments · May be fixed by #29

Comments

@rjurney
Copy link

rjurney commented Jan 31, 2025

NOTE: I figured out my issue. relik requires numpy==1.26.4 and it isn't pinned as a dependency in the package. This means your package manager is likely to install numpy==2.0.2 which is the latest as of January 30, 2025. This will confuse relik and it will not function. Downgrade to numpy==1.26.4 and all will be well...

My environment is:

  • Anaconda Python 3.11.11
  • conda environment
  • Poetry 2.0.1
  • relik==1.0.7
  • Other than some dependencies like black and isort, relik is the only package I have installed via poetry add relik.

When I run the hello world:

from relik import Relik
from relik.inference.data.objects import RelikOutput

relik = Relik.from_pretrained("sapienzanlp/relik-entity-linking-large")
relik_out: RelikOutput = relik("Michael Jordan was one of the best players in the NBA.")

I get this numpy dimension exception, straight away:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 from relik import Relik
      2 from relik.inference.data.objects import RelikOutput
      4 relik = Relik.from_pretrained("sapienzanlp/relik-entity-linking-large")

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/relik/__init__.py:1
----> 1 from relik.inference.annotator import Relik
      2 from pathlib import Path
      4 VERSION = {}  # type: ignore

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/relik/inference/annotator.py:26
     24 from relik.inference.data.splitters.base_sentence_splitter import BaseSentenceSplitter
     25 from relik.inference.data.splitters.blank_sentence_splitter import BlankSentenceSplitter
---> 26 from relik.inference.data.splitters.spacy_sentence_splitter import SpacySentenceSplitter
     27 from relik.inference.data.splitters.window_based_splitter import WindowSentenceSplitter
     28 from relik.inference.data.tokenizers.spacy_tokenizer import SpacyTokenizer

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/relik/inference/data/splitters/spacy_sentence_splitter.py:3
      1 from typing import Any, Iterable, List, Optional, Union
----> 3 import spacy
      5 from relik.inference.data.objects import Word
      6 from relik.inference.data.splitters.base_sentence_splitter import BaseSentenceSplitter

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/spacy/__init__.py:6
      3 from typing import Any, Dict, Iterable, Union
      5 # set library-specific custom warning handling before doing anything else
----> 6 from .errors import setup_default_warnings
      8 setup_default_warnings()  # noqa: E402
     10 # These are imported as part of the API

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/spacy/errors.py:3
      1 import warnings
----> 3 from .compat import Literal
      6 class ErrorsWithCodes(type):
      7     def __getattribute__(self, code):

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/spacy/compat.py:39
     36 except ImportError:
     37     from catalogue import _importlib_metadata as importlib_metadata  # type: ignore[no-redef]    # noqa: F401
---> 39 from thinc.api import Optimizer  # noqa: F401
     41 pickle = pickle
     42 copy_reg = copy_reg

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/thinc/api.py:1
----> 1 from .backends import (
      2     CupyOps,
      3     MPSOps,
      4     NumpyOps,
      5     Ops,
      6     get_current_ops,
      7     get_ops,
      8     set_current_ops,
      9     set_gpu_allocator,
     10     use_ops,
     11     use_pytorch_for_gpu_memory,
     12     use_tensorflow_for_gpu_memory,
     13 )
     14 from .compat import enable_mxnet, enable_tensorflow, has_cupy
     15 from .config import Config, ConfigValidationError, registry

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/thinc/backends/__init__.py:17
     15 from ._cupy_allocators import cupy_pytorch_allocator, cupy_tensorflow_allocator
     16 from ._param_server import ParamServer
---> 17 from .cupy_ops import CupyOps
     18 from .mps_ops import MPSOps
     19 from .numpy_ops import NumpyOps

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/thinc/backends/cupy_ops.py:16
      6 from ..util import (
      7     is_cupy_array,
      8     is_mxnet_gpu_array,
   (...)
     13     torch2xp,
     14 )
     15 from . import _custom_kernels
---> 16 from .numpy_ops import NumpyOps
     17 from .ops import Ops
     20 @registry.ops("CupyOps")
     21 class CupyOps(Ops):

File ~/anaconda3/envs/iecompare/lib/python3.11/site-packages/thinc/backends/numpy_ops.pyx: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

It looks like relik expects a certain version of numpy that isn't getting installed correctly when I poetry add relik.

Please advice... I am writing a blog post entitled Three New Information Extraction Models Compared about this project, comparing it with GLiREL and NuExtract. This stopped me straight away. I am going to test the other two and come back here and debug this bad boy. In the meantime maybe you will get back to me :)

@rjurney rjurney changed the title ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject numpy v2.0.2 fail: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject Jan 31, 2025
rjurney added a commit to rjurney/relik that referenced this issue Jan 31, 2025
This PR fixes SapienzaNLP#28 by pinning `numpy==1.26.4`.
@rjurney rjurney linked a pull request Jan 31, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant