ValueError:numpy.ndarray 大小已更改,可能表示二进制不兼容

问题描述 投票:0回答:3

我正在尝试让

numpy<1.19.0
ConfigSpace==0.4.16
python==3.7
conda 环境中工作。
numpy
的安装版本是
1.18.5

我收到以下错误:

Traceback (most recent call last):
  File "/home/user/.conda/envs/deephyper/bin/deephyper", line 5, in <module>
    from deephyper.core.cli import main
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/core/cli/__init__.py", line 1, in <module>
    from deephyper.core.cli.cli import main
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/core/cli/cli.py", line 9, in <module>
    from deephyper.core.cli import hps, nas, balsam_submit
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/core/cli/hps.py", line 6, in <module>
    from deephyper.search.util import load_attr_from
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/search/__init__.py", line 6, in <module>
    from deephyper.search.search import Search
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/search/search.py", line 8, in <module>
    from deephyper.evaluator.evaluate import Evaluator
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/evaluator/__init__.py", line 5, in <module>
    from deephyper.evaluator.evaluate import Encoder
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/deephyper/evaluator/evaluate.py", line 15, in <module>
    import skopt
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/__init__.py", line 45, in <module>
    from . import callbacks
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/callbacks.py", line 17, in <module>
    from skopt.utils import dump
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/utils.py", line 19, in <module>
    from .sampler import Sobol, Lhs, Hammersly, Halton, Grid
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/sampler/__init__.py", line 4, in <module>
    from .lhs import Lhs
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/sampler/lhs.py", line 9, in <module>
    from ..space import Space, Categorical
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/space/__init__.py", line 5, in <module>
    from .space import *
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/skopt/space/space.py", line 27, in <module>
    import ConfigSpace as CS
  File "/home/user/.conda/envs/deephyper/lib/python3.7/site-packages/ConfigSpace/__init__.py", line 37, in <module>
    from ConfigSpace.configuration_space import Configuration, \
  File "ConfigSpace/configuration_space.pyx", line 39, in init ConfigSpace.configuration_space
  File "ConfigSpace/hyperparameters.pyx", line 1, in init ConfigSpace.hyperparameters
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

我尝试了其他类似问题中建议的解决方案,例如尝试其他版本的

numpy
或删除所有
numpy
安装并重新安装
numpy
ConfigSpace
以及
pip
选项
--no-cache-dir --no-binary
,但错误仍然存在。

我可以尝试其他潜在的解决方案吗?

python python-3.x pip runtime-error compatibility
3个回答
4
投票

通过查阅此 GitHub 问题页面,我对这个问题有了一些额外的了解。事实证明,如果 PyObject 的大小小于 C 标头的大小,则需要升级错误引用的包(此处

numpy
)才能解决错误,反之亦然。

我能够通过将

numpy
升级到版本
1.20.0
来解决该问题,即使要求是
numpy<1.19.0


1
投票

分享这个以防对其他人有帮助:我试图让 fairseq 工作,并遇到了同样的

ValueError
问题,可能的原因是二进制不兼容,而 Jake 的 suggestion 将 numpy 更新为
1.20.0
帮助解决了即使通过特别要求的要求也会出现问题
numpy<1.19.0


1
投票

我遇到了同样的问题:

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
,这个解决方案对我有用。具体来说,使用 Dockerfile 创建镜像,我安装 flair==0.8.0.post1,这需要 numpy<1.19.0. But after installing flair==0.8.0.post1 I install numpy==1.20.0 and this has avoided the problem. This section of the Dockerfile is:

RUN pip install flair==0.8.0.post1
RUN pip install numpy==1.20.0
© www.soinside.com 2019 - 2024. All rights reserved.