'Error "Numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject."

I got this error file while following this tutorial: https://www.youtube.com/watch?v=yqkISICHH-U

So far I have created a training dataset to feed into Tensorflow. I am using transfer learning on one of the pre-trained TensorFlow object recognition models. I get the error when I attempt to train the model with my new dataset. This is a picture of the full error message that shows up.

I attempted to solve the problem by trying the following:

  • Reinstalling Numpy
  • Installing Numpy 1.20.x
  • Installing Numpy 1.18.x
  • Reinstalling pycocotools

When I installed Numpy 1.20.x the error went away and was replaced with a separate error: notimplementederror: cannot convert a symbolic Tensor (cond_2/strided:0) to a numpy array. This seemed to be a compatibility issue between Tensorflow and Numpy 1.20.x. When debugging this error, I found that everyone solved it by downgrading their Numpy to 1.19.x. However, in my case I am still left with the first error.

I am using python 3.8.9 with anaconda. Here are the packages I have installed: https://pastebin.com/BNW8tU2A

(tfod) (base) C:\Users\piper\python\Tensorflow\TFODCourse>pip list
Package                 Version             Location
----------------------- ------------------- ---------------------------------------------------------------------------
absl-py                 0.13.0
astunparse              1.6.3
backcall                0.2.0
cachetools              4.2.2
certifi                 2021.5.30
charset-normalizer      2.0.3
colorama                0.4.4
cycler                  0.10.0
Cython                  0.29.24
debugpy                 1.3.0
decorator               5.0.9
flatbuffers             1.12
gast                    0.4.0
gin-config              0.4.0
google-auth             1.33.1
google-auth-oauthlib    0.4.4
google-cloud-bigquery   1.21.0
google-pasta            0.2.0
grpcio                  1.34.1
h5py                    3.1.0
idna                    3.2
ipykernel               6.0.3
ipython                 7.25.0
ipython-genutils        0.2.0
jedi                    0.18.0
jupyter-client          6.1.12
jupyter-core            4.7.1
keras-nightly           2.5.0.dev2021032900
Keras-Preprocessing     1.1.2
kiwisolver              1.3.1
lvis                    0.5.3
lxml                    4.6.3
Markdown                3.3.4
matplotlib              3.2.0
matplotlib-inline       0.1.2
numpy                   1.19.5
oauthlib                3.1.1
object-detection        0.1
opencv-python           4.5.3.56
opt-einsum              3.3.0
pandas                  1.3.0
parso                   0.8.2
pickleshare             0.7.5
Pillow                  8.3.1
pip                     21.1.3
prompt-toolkit          3.0.19
protobuf                3.17.3
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycocotools             2.0.2
Pygments                2.9.0
pyparsing               2.4.7
PyQt5                   5.15.4
PyQt5-Qt5               5.15.2
PyQt5-sip               12.9.0
python-dateutil         2.8.2
pytz                    2021.1
pywin32                 225
PyYAML                  5.4.1
pyzmq                   22.1.0
requests                2.26.0
requests-oauthlib       1.3.0
rsa                     4.7.2
scipy                   1.7.0
setuptools              49.2.1
six                     1.15.0
slim                    0.1                 c:\users\piper\python\tensorflow\tfodcourse\tensorflow\models\research\slim
tensorboard             2.5.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
tensorflow              2.5.0
tensorflow-addons       0.13.0
tensorflow-estimator    2.5.0
tensorflow-gpu          2.5.0
termcolor               1.1.0
tf-models-official      2.5.0
tf-slim                 1.1.0
tornado                 6.1
traitlets               5.0.5
typeguard               2.12.1
typing-extensions       3.7.4.3
urllib3                 1.26.6
wcwidth                 0.2.5
Werkzeug                2.0.1
wget                    3.2
wheel                   0.36.2
wrapt                   1.12.1

Any help would be appreciated!

So I solved the issue by reinstalling pycocotools with the --no-cache-dir flag. So I did:

pip uninstall pycocotools
pip install --no-cache-dir pycocotools

This completely solved the issue.



Solution 1:[1]

I had the same problem with python3.6 in a virtual environment. Reinstalling with the --no-cache-dir flag didn't solve the problem.

I solved the problem by starting from fresh in a virtual environment with python3.7

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yonatan Simson