I tried running cython compile time optimization on FastAPI serving layer in python during ML Model inferencing. Instead of loading plain python module for ML Model , I tried loading cython compile ML Module in FastAPI Server.
I am getting below error while loading ML Model while running on Mac OS Monterey ( Version 12.5)
Getting invalid ELF header issue
Command to used to compile python file
python setup.py build_ext --inplace
Content of setup.py file
from distutils.core import setup from Cython.Build import cythonize setup(ext_modules = cythonize('v2/model.pyx','v2/model_config.pyx','v2/utils.pyx'), extra_compile_args=["-mmacosx-version-min=10.9", "-stdlib=libc++"], extra_link_args=["-mmacosx-version-min=10.9", "-stdlib=libc++"], )
File which I has trying to load in python code model.cpython-310-darwin.so
Any help would be appreciated here
- I tried in normal Mac laptop ( without M1 chip) , faced same issue there.
- Also , trying changing -mmacosx-version-min=10.9 setting as per Mac version , it did not help to me.