herokudeploymentbuildpackopenvinoheroku-api

Heroku not seeing OpenVino when trying to deploy


I have an OpenVino model I'm trying to deploy via Heroku. The app runs on the machine (since OpenVino is installed on the machine in the /opt/intel directory). Even after successfully installing OpenVino with pip, I'd make the import but still get the error message:

ImportError: dlopen(/opt/intel/openvino_2021/python/python3.9/openvino/inference_engine/ie_api.so, 2): Symbol not found: _PyCMethod_New
  Referenced from: /opt/intel/openvino_2021/python/python3.9/openvino/inference_engine/ie_api.so
  Expected in: flat namespace

when trying to import OpenVino in the script. For that reason, I gave up on using pip and instead built OpenVino from source on the machine. The script can run fine with OpenVino on the machine, but the question is how to deploy this to Heroku without including OpenVino in the requirements.txt file generated with pip freeze.

Specifying OpenVino in the requirements.txt for Heroku does not work (not simple to install with pip as explained above), so I tried to move the expected OpenVino folder into the venv folder. In the project folder, I copied the OpenVino folder into venv > lib > python3.9 > sitepackages. However, once deployed to Heroku that seems to have no effect and I still get the following error in the Heroku logs:

2022-01-06T19:39:59.115102+00:00 app[web.2]: File "./main.py", line 26, in <module>
2022-01-06T19:39:59.115206+00:00 app[web.2]: from openvino.inference_engine import IECore, IENetwork
2022-01-06T19:39:59.115219+00:00 app[web.2]: File "/app/.heroku/python/lib/python3.9/site-packages/openvino/inference_engine/__init__.py", line 30, in <module>
2022-01-06T19:39:59.115309+00:00 app[web.2]: from .ie_api import *
2022-01-06T19:39:59.115333+00:00 app[web.2]: ImportError: libpython3.9.so.1.0: cannot open shared object file: No such file or directory

So the expected folder is not there. Of course, for Heroku it's also a different directory structure:

/app/.heroku/python/lib/python3.9/site-packages/

Instead of:

/venv/lib/python3.9/site-packages

However I need to get openvino in that site-packages directory for the Heroku app.

How can I manually add the expected openvino folder to /app/.heroku/python/lib/python3.9/site-packages? If that's not possible, how can I edit the buildpack to install openvino for the Heroku app?

Any help would be much appreciated.

Thanks!


Solution

  • The error you encountered: ImportError: libpython3.9.so.1.0: cannot open shared object file: No such file or directory was due to missing external dependency on Heroku.

    Follow the steps below to resolve this issue:

    Add a runtime.txt to your app’s root directory to specify a Python runtime. Refer to Selecting a runtime.

    python-3.8.12
    

    Add an Aptfile to your app’s root directory to add support for apt-based dependencies during both compile and runtime. Refer to heroku-buildpack-apt.

    libpython3.8