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

Valueerror: numpy.ndarray size changed... when I try to import GPy #936

Open
NiranthS opened this issue Jul 2, 2021 · 3 comments
Open

Comments

@NiranthS
Copy link

NiranthS commented Jul 2, 2021

Hello
I installed the latest GPy version using pip install, but when I try importing I have the error:
from . import linalg_cython
File "GPy/util/linalg_cython.pyx", line 1, in init GPy.util.linalg_cython
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

Some solutions on the internet tell to just try uninstalling and installing NumPy. This changes the NumPy version to the latest one(1.20.x) which is not compatible with TensorFlow. Tensorflow works with only numpy <= 1.19.5

Can you please help me in resolving this so that I can use both TensorFlow and GPy together

Thanks in advance!

@sshojiro
Copy link

sshojiro commented Jul 4, 2021

Hi,

(I'm not a GPy specialist, btw)
I encountered the same issue and a solution: #924 (comment). According to a post on StackOverFlow mentions to reinstall of numpy; however, it did not work for me. Instead, I attempted to install numpy==1.20.0 just in case and it worked as follows.

$ python -c 'import GPy'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\USRE\Anaconda3\envs\picon\lib\site-packages\GPy\__init__.py", line 6, in <module>
    from . import core
  File "C:\Users\USER01\Anaconda3\envs\picon\lib\site-packages\GPy\core\__init__.py", line 49, in <module>
    from .gp import GP
  File "C:\Users\USER01\Anaconda3\envs\picon\lib\site-packages\GPy\core\gp.py", line 8, in <module>
    from .. import likelihoods
  File "C:\Users\USER01\Anaconda3\envs\picon\lib\site-packages\GPy\likelihoods\__init__.py", line 25, in <module>
    from .bernoulli import Bernoulli
  File "C:\Users\USER01\Anaconda3\envs\picon\lib\site-packages\GPy\likelihoods\bernoulli.py", line 5, in <module>
    from ..util.univariate_Gaussian import std_norm_pdf, std_norm_cdf, derivLogCdfNormal, logCdfNormal
  File "C:\Users\USER01\Anaconda3\envs\picon\lib\site-packages\GPy\util\__init__.py", line 11, in <module>
    from . import linalg
  File "C:\Users\USER01\Anaconda3\envs\picon\lib\site-packages\GPy\util\linalg.py", line 15, in <module>
    from . import linalg_cython
  File "GPy/util/linalg_cython.pyx", line 1, in init GPy.util.linalg_cython
    from libc.math cimport sqrt
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

$ pip uninstall numpy -y && pip install numpy==1.20.0
Found existing installation: numpy 1.19.0
Uninstalling numpy-1.19.0:
  Successfully uninstalled numpy-1.19.0
Collecting numpy==1.20.0
  Downloading numpy-1.20.0-cp37-cp37m-win_amd64.whl (13.6 MB)
Installing collected packages: numpy
Successfully installed numpy-1.20.0

$ python -c 'import GPy'

$ python -V
Python 3.7.0
$ pip list | grep GPy
GPy                 1.10.0

Best,
SS

@NiranthS
Copy link
Author

NiranthS commented Jul 5, 2021

Thanks for the comment @sshojiro
I tried installing numpy 1.20, but it was causing problems in TensorFlow. I think TensorFlow supports numpy <=1.19.5 only

@vnmabus
Copy link

vnmabus commented Mar 30, 2022

This actually is the same as #974. pip compiles GPy against the currently installed NumPy, or the latest one if no NumPy is installed, because the build requirement is wrong. Then a previous (ABI-incompatible) version of NumPy is installed because of the TensorFlow requirement.

This should be fixed by #975. As a workaround, you can try to install an older version of NumPy (such as 1.17), compile GPy against it, and then upgrade the NumPy version.

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

3 participants