0

I have a project in which I use a rq worker in conjuction with tensorflow to predict the genre of songs recorded on a microphone (Raspberry pi4).

The problem is: when i use the function to predict the genre i get an error on the rq worker that says:

2021-09-13 10:49:30.246680: E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
10:49:33 Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/rq/worker.py", line 1031, in perform_job
    rv = job.perform()
  File "/home/pi/.local/lib/python3.7/site-packages/rq/job.py", line 749, in perform
    self._result = self._execute()
  File "/home/pi/.local/lib/python3.7/site-packages/rq/job.py", line 772, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/rq/job.py", line 225, in func
    return import_attribute(self.func_name)
  File "/home/pi/.local/lib/python3.7/site-packages/rq/utils.py", line 142, in import_attribute
    module = importlib.import_module(module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./recognition.py", line 1, in <module>
    from tensorflow.keras import layers
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "<frozen importlib._bootstrap>", line 1019, in _handle_fromlist
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 50, in __getattr__
    module = self._load()
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/__init__.py", line 88, in <module>
    from tensorflow.python import keras
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
    from tensorflow.python.keras import activations
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
    from tensorflow.python.keras import activations
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/activations.py", line 23, in <module>
    from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/__init__.py", line 34, in <module>
    from tensorflow.python.keras.utils.io_utils import HDF5Matrix
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/io_utils.py", line 30, in <module>
    import h5py
  File "/home/pi/.local/lib/python3.7/site-packages/h5py/__init__.py", line 25, in <module>
    from . import _errors
  File "h5py/_errors.pyx", line 1, in init h5py._errors
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 44 from C header, got 40 from PyObject
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/rq/worker.py", line 1031, in perform_job
    rv = job.perform()
  File "/home/pi/.local/lib/python3.7/site-packages/rq/job.py", line 749, in perform
    self._result = self._execute()
  File "/home/pi/.local/lib/python3.7/site-packages/rq/job.py", line 772, in _execute
    result = self.func(*self.args, **self.kwargs)
  File "/home/pi/.local/lib/python3.7/site-packages/rq/job.py", line 225, in func
    return import_attribute(self.func_name)
  File "/home/pi/.local/lib/python3.7/site-packages/rq/utils.py", line 142, in import_attribute
    module = importlib.import_module(module_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./recognition.py", line 1, in <module>
    from tensorflow.keras import layers
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "<frozen importlib._bootstrap>", line 1019, in _handle_fromlist
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 50, in __getattr__
    module = self._load()
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow/__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/__init__.py", line 88, in <module>
    from tensorflow.python import keras
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
    from tensorflow.python.keras import activations
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
    from tensorflow.python.keras import activations
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/activations.py", line 23, in <module>
    from tensorflow.python.keras.utils.generic_utils import deserialize_keras_object
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/__init__.py", line 34, in <module>
    from tensorflow.python.keras.utils.io_utils import HDF5Matrix
  File "/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/io_utils.py", line 30, in <module>
    import h5py
  File "/home/pi/.local/lib/python3.7/site-packages/h5py/__init__.py", line 25, in <module>
    from . import _errors
  File "h5py/_errors.pyx", line 1, in init h5py._errors
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 44 from C header, got 40 from PyObject

I know it's a lot of text but i have no clue on how to fix the error. Also I want to specify that the rq worker works fine with other functions that does not require the Tensorflow library.

  • There's a lot of very similar errors (if not the same) if you do a search here. Have you tried [this one](https://stackoverflow.com/questions/66060487/valueerror-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-exp) for example? – nitrin0 Sep 13 '21 at 12:14
  • Did you install dependencies as mentioned in this threads? https://github.com/PINTO0309/Tensorflow-bin#usage https://raspberrypi.stackexchange.com/a/107920 –  Mar 05 '22 at 04:58

0 Answers0