Skip to content

Lambda execution environment has older version of GLIBC

0

When running my Lambda (python which does import face_recognition which needs GLib ) I see the following error:

{
  "errorMessage": "Unable to import module 'functions/facevectorhandler': /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /var/task/_dlib_pybind11.cpython-310-x86_64-linux-gnu.so)",
  "errorType": "Runtime.ImportModuleError",
  "requestId": "bf1ddbb2-4a2e-4cc3-a213-6d82329cf7cc",
  "stackTrace": []
}

Which I understand is because the Lambda execution environment only has an older version of GLIBC available.

  1. How can I find out which version of GLib is available natively
  2. is there a way to get an environment with a newer execution environment/GLib version ?

Is this bound by the selected Python version ( 3.10) ?

asked 2 years ago3.2K views
2 Answers
0
Accepted Answer

The Python 3.12 runtime in AWS Lambda is based on AL2023, which includes a newer glibc version: https://aws.amazon.com/blogs/compute/python-3-12-runtime-now-available-in-aws-lambda/

answered 2 years ago
EXPERT
reviewed 10 months ago
0

Hello,

Thank you for your question. My name is Esther, and I'm an AWS Support Engineer who will be assisting you today.

Question 1. How can I find out which version of GLib is available natively?

Regarding the Lambda runtimes, you can find the list of supported environments at this link: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported.

This page outlines the operating system and available libraries for each runtime. While the specific library versions within each runtime are not published, you can use the following code to check the glibc version in python:

import os
print(os.system("ldd --version"))

Question 2. Is there a way to get an environment with a newer execution environment/GLib version ?

To get an environment with a newer execution environment or glibc version, you have a few options:

  1. Upgrade to Python 3.12: Python 3.12 uses Amazon Linux 2023 (AL2023), which will have a newer glibc version. This is a minor Python version upgrade, so the language changes should be minimal. However, I would still recommend thoroughly testing any implementations before applying them to a production environment.

  2. Use a custom container image: You can create a custom container image for your Lambda function, which allows you to specify the exact environment you need, including the glibc version. When using a custom container, it becomes your responsibility to maintain the image and apply any necessary updates. This option provides more flexibility but requires more maintenance. Refer to the link[2] for more information.

  3. Bring your own glibc version using layers: If you prefer to stick to the stock Lambda environment, you can create a custom layer[3] with the desired glibc version and use it with your Lambda function. This involves compiling the layer on an Amazon Linux 2 environment and packaging it according to the guidelines[4]. You'll then need to update your code to modify the PATH and import the custom glibc version.

There is a good example of this approach with Boto3 in this third-party blog post: [5] In the "Utilizing Newer Versions of boto3 and botocore" section, you can find details on how to use a custom layer to bring in a newer version of a library, which you can apply to bringing in a newer glibc version as well.

Question 3: Is this bound by the selected Python version ( 3.10) ?

Yes the Glibc version is bound to the python version. However, you can update the glibc versions by the recommendations given above.

Please review the linked documentation for more details on each of these options. Let me know if you have any further questions or if there's anything else I can assist you with.

[1]. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-supported

[2]. https://docs.aws.amazon.com/lambda/latest/dg/images-create.html

[3]. https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html

[4]. https://docs.aws.amazon.com/lambda/latest/dg/packaging-layers.html

[5]. https://www.mandsconsulting.com/lambda-functions-with-newer-version-of-boto3-than-available-by-default/

AWS
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.