James Scott
James Scott

Reputation: 181

Python AWS Lambda Error "libgomp.so.1: cannot open shared object file: No such file or directory" from AWS EFS file system mounted on Ubuntu

I have an AWS lambda function connected to an AWS EFS mounted on a EC2 instance of Ubunutu 18. I am getting this error below when importing a LightGBM model i believe.

    {
  "errorMessage": "libgomp.so.1: cannot open shared object file: No such file or directory",
  "errorType": "OSError",
  "stackTrace": [
    "  File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n",
    "  File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n    module = _load(spec)\n",
    "  File \"<frozen importlib._bootstrap>\", line 702, in _load\n",
    "  File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 848, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
    "  File \"/var/task/lambda_function.py\", line 9, in <module>\n    from supervised.automl import AutoML\n",
    "  File \"/mnt/access/supervised/__init__.py\", line 3, in <module>\n    from supervised.automl import AutoML\n",
    "  File \"/mnt/access/supervised/automl.py\", line 3, in <module>\n    from supervised.base_automl import BaseAutoML\n",
    "  File \"/mnt/access/supervised/base_automl.py\", line 21, in <module>\n    from supervised.algorithms.registry import AlgorithmsRegistry\n",
    "  File \"/mnt/access/supervised/algorithms/registry.py\", line 74, in <module>\n    import supervised.algorithms.lightgbm\n",
    "  File \"/mnt/access/supervised/algorithms/lightgbm.py\", line 8, in <module>\n    import lightgbm as lgb\n",
    "  File \"/mnt/access/lightgbm/__init__.py\", line 8, in <module>\n    from .basic import Booster, Dataset\n",
    "  File \"/mnt/access/lightgbm/basic.py\", line 43, in <module>\n    _LIB = _load_lib()\n",
    "  File \"/mnt/access/lightgbm/basic.py\", line 34, in _load_lib\n    lib = ctypes.cdll.LoadLibrary(lib_path[0])\n",
    "  File \"/var/lang/lib/python3.8/ctypes/__init__.py\", line 451, in LoadLibrary\n    return self._dlltype(name)\n",
    "  File \"/var/lang/lib/python3.8/ctypes/__init__.py\", line 373, in __init__\n    self._handle = _dlopen(self._name, mode)\n"
  ]
}

My package list installed

ubuntu@ip-***-**-**-***:~/mounted/access$ ls
ConfigSpace                    category_encoders-2.2.2.dist-info  examples                                   matplotlib                         plotlywidget                     scikit_plot-0.3.7.dist-info       tabulate.py
ConfigSpace-0.4.19.dist-info   click                              fsspec                                     matplotlib-3.4.2-py3.8-nspkg.pth   pluggy                           scikitplot                        tblib
Cython                         click-8.0.1.dist-info              fsspec-2021.5.0.dist-info                  matplotlib-3.4.2.dist-info         pluggy-0.13.1.dist-info          scipy                             tblib-1.7.0.dist-info
Cython-0.29.23.dist-info       cliff                              graphviz                                   mljar_supervised-0.10.4.dist-info  prettytable                      scipy-1.6.1.dist-info             testing
HeapDict-1.0.1.dist-info       cliff-3.8.0.dist-info              graphviz-0.16.dist-info                    mpl_toolkits                       prettytable-2.1.0.dist-info      scipy-1.6.3.dist-info             threadpoolctl-2.1.0.dist-info
Mako-1.1.4.dist-info           cloudpickle                        greenlet                                   msgpack                            psutil                           scipy.libs                        threadpoolctl.py
Markdown-3.3.4.dist-info       cloudpickle-1.3.0.dist-info        greenlet-1.1.0.dist-info                   msgpack-1.0.2.dist-info            psutil-5.8.0.dist-info           seaborn                           tlz
MarkupSafe-2.0.1.dist-info     cloudpickle-1.6.0.dist-info        heapdict.py                                numba                              py                               seaborn-0.11.1.dist-info          toml
PIL                            cmaes                              include                                    numba-0.48.0.dist-info             py-1.10.0.dist-info              setuptools                        toml-0.10.2.dist-info
Pillow-8.2.0.dist-info         cmaes-0.8.2.dist-info              iniconfig                                  numba-0.53.1.dist-info             pyarrow                          setuptools-57.0.0.dist-info       toolz
Pillow.libs                    cmd2                               iniconfig-1.1.1.dist-info                  numpy                              pyarrow-4.0.1.dist-info          shap                              toolz-0.11.1.dist-info
PyYAML-5.4.1.dist-info         cmd2-1.5.0.dist-info               intel_openmp-2021.2.0.dist-info            numpy-1.20.3.dist-info             pylab.py                         shap-0.36.0.dist-info             tornado
SQLAlchemy-1.4.17.dist-info    colorama                           joblib                                     numpy.libs                         pynisher                         share                             tornado-6.1.dist-info
__pycache__                    colorama-0.4.4.dist-info           joblib-1.0.1.dist-info                     optuna                             pynisher-0.6.4.dist-info         six-1.16.0.dist-info              tqdm
_distutils_hack                colorlog                           kiwisolver-1.3.1.dist-info                 optuna-2.7.0.dist-info             pyparsing-2.4.7.dist-info        six.py                            tqdm-4.61.0.dist-info
_plotly_future_                colorlog-5.0.1.dist-info           kiwisolver.cpython-38-x86_64-linux-gnu.so  packaging                          pyparsing.py                     sklearn                           wcwidth
_plotly_utils                  colour-0.1.5.dist-info             lazy_import                                packaging-20.9.dist-info           pyperclip                        sklearn-0.0.dist-info             wcwidth-0.2.5.dist-info
_pytest                        colour.py                          lazy_import-0.2.2.dist-info                pandas                             pyperclip-1.8.2.dist-info        slicer                            wheel
_yaml                          cycler-0.10.0.dist-info            liac_arff-2.5.0.dist-info                  pandas-1.2.0.dist-info             pyrfr                            slicer-0.0.7.dist-info            wheel-0.36.2.dist-info
alembic                        cycler.py                          licensing                                  pandas-1.2.4.dist-info             pyrfr-0.8.2.dist-info            smac                              wordcloud
alembic-1.6.5.dist-info        cython.py                          lightgbm                                   partd                              pytest                           smac-0.13.1.dist-info             wordcloud-1.8.1.dist-info
apt.txt                        dask                               lightgbm-3.0.0.dist-info                   partd-1.2.0.dist-info              pytest-6.2.4.dist-info           somefile.txt                      xgboost
arff.py                        dask-2021.6.0.dist-info            llvmlite                                   patsy                              python_dateutil-2.8.1.dist-info  sortedcontainers                  xgboost-1.3.3.dist-info
attr                           dateutil                           llvmlite-0.31.0.dist-info                  patsy-0.5.1.dist-info              python_editor-1.0.4.dist-info    sortedcontainers-2.4.0.dist-info  xgboost-1.4.2.dist-info
attrs-21.2.0.dist-info         distributed                        llvmlite-0.36.0.dist-info                  pbr                                pytz                             sqlalchemy                        xgboost.libs
auto_sklearn-0.12.6.dist-info  distributed-2021.6.0.dist-info     local                                      pbr-5.6.0.dist-info                pytz-2021.1.dist-info            statsmodels                       yaml
autosklearn                    distutils-precedence.pth           locket                                     pip                                pyximport                        statsmodels-0.12.2.dist-info      zict
bin                            dtreeviz                           locket-0.2.1.dist-info                     pip-21.1.2.dist-info               retrying-1.3.3.dist-info         stevedore                         zict-2.0.0.dist-info
catboost                       dtreeviz-1.3.dist-info             mako                                       pkg_resources                      retrying.py                      stevedore-3.3.0.dist-info
catboost-0.24.4.dist-info      editor.py                          markdown                                   plotly                             scikit_learn-0.24.2.dist-info    supervised
category_encoders              etc                                markupsafe                                 plotly-4.14.3.dist-info            scikit_learn.libs                tabulate-0.8.7.dist-info

if anyone knows how to resolves this error or if more information is needed please help!

Function Logs
START RequestId: 576d0bf7-1cdb-4f98-bd6d-ba807d0af0bb Version: $LATEST
OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k
/mnt/access/joblib/_multiprocessing_helpers.py:45: UserWarning: [Errno 38] Function not implemented.  joblib will operate in serial mode
  warnings.warn('%s.  joblib will operate in serial mode' % (e,))
OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k
[WARNING]   2021-06-05T00:57:04.711Z        Matplotlib created a temporary config/cache directory at /tmp/matplotlib-bw2u754h because the default path (/home/sbx_user1051/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
[ERROR] OSError: libgomp.so.1: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/var/lang/lib/python3.8/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/var/lang/lib/python3.8/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/lambda_function.py", line 9, in <module>
    import lightgbm
  File "/mnt/access/lightgbm/__init__.py", line 8, in <module>
    from .basic import Booster, Dataset, register_logger
  File "/mnt/access/lightgbm/basic.py", line 95, in <module>
    _LIB = _load_lib()
  File "/mnt/access/lightgbm/basic.py", line 86, in _load_lib
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
  File "/var/lang/lib/python3.8/ctypes/__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "/var/lang/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)END RequestId: 576d0bf7-1cdb-4f98-bd6d-ba807d0af0bb
REPORT RequestId: 576d0bf7-1cdb-4f98-bd6d-ba807d0af0bb  Duration: 22908.85 ms   Billed Duration: 22909 ms   Memory Size: 5000 MB    Max Memory Used: 243 MB 
Unknown application error occurred

This is the log from the AWS lambda function, i have libgomp1 installed on my ec2 Ubuntu envirorment however im not to sure if the problem is in lambda or ubuntu. I can do an import of lightgbm just fine

Upvotes: 5

Views: 2614

Answers (1)

nuri
nuri

Reputation: 240

It's worth noting that the versions of libgomp.so and glibc can vary depending on the Amazon Lambda runtime version. For more information, refer to https://repost.aws/questions/QUrXOioL46RcCnFGyELJWKLw/glibc-2-27-on-amazon-linux-2. enter image description here To address this, you can create a custom AWS Lambda layer by provisioning an Amazon Linux 2 instance on an EC2, downloading the required libgomp.so and glibc packages, and packaging them into a Lambda layer. Ensure that the AWS Lambda layer objects are located under the /lib folder, as specified in the documentation: https://docs.aws.amazon.com/lambda/latest/dg/packaging-layers.html.

Once this layer is added, the Lightgbm library should be importable in your Lambda environment.

here my layer for python 3.8! AWS-Lambda-Layers-v0.zip

Upvotes: 0

Related Questions