9

I would like to deploy and test my Lambda function, but, every time I try to do that I am getting following error message:

2019-11-11 13:25:33 Mounting /tmp/tmphebm3s_4 as /var/task:ro,delegated inside runtime container
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libopencv_dnn.so.4.1)
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libopencv_video.so.4.1)
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libopencv_objdetect.so.4.1)
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libopencv_features2d.so.4.1)
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libopencv_imgproc.so.4.1)
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libopencv_core.so.4.1)
/var/task/bin/inference: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/lib/libinference_engine.so)
/var/task/bin/inference: /lib64/libdbus-1.so.3: no version information available (required by /opt/lib/libatk-bridge-2.0.so.0)
^C/var/task/bin/inference: /lib64/libdbus-1.so.3: no version information available (required by /opt/lib/libatspi.so.0)
Makefile:85: recipe for target 'run-inference' failed

Note that inference is name of my Lambda functions binary.

I found about this link: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-linux-binary-package/ that lets me use Amazon Linux box in order to create deployment package adequate for Lambda function execution environment.

My plan was to copy code to EC2 instance and build it with GLIBC version installed on it. I think that this would fix issue mentioned above.

Problem is that, once I SSH to EC2 instance, how do I copy my code to it and then build it? I am not an expert in linux so this is kinda confusing to me.

Thanks in advance!

Stefan Radonjic
  • 1,449
  • 4
  • 19
  • 38

3 Answers3

3

I have just answered a similar question that addresses that issue you had, in which was the same issue I had earlier today. Please look at:

How can I use environmental variables on AWS Lambda?

In addition to looking there, please note that you will have to pack a layer into your AWS Lambda Function in which will need to have the correct LIB files -- "libm.so.6" is one for example -- in the lib folder of your layer. After that, you will need to set up the environmental variable, as explained in the link above, so that the correct lib file of your layer is used at runtime and thus your code runs successfully.

In order to get the correct LIB file, I would suggest googling more, and also trying to run your code in conda. My project was developed in a conda environment, and when I translated into a virtualenv so that I could package into a Layer and then upload to AWS Lambda, I noticed that I was getting that error too. I then grabbed the correct lib file from either (don't remember now) the lib folder of my conda environment, or the lib folder of the conda installation directory, and I placed in the lib folder of my layer package. After that, I stll had to set the environment variable so that those specific lib files would load and be linked to the python runtime.

Raphael Setin
  • 557
  • 5
  • 10
0

The problem here lies in incompatibility between the version of OpenCV that you are trying to use and Amazon Linux, the OS that runs it. Basically, you are trying to use OpenCV compiled for a different system and it can't run.

To solve this, you need to build OpenCV for Amazon Linux and for the current version of the programming language that you use. Here is a repository for Python 3.7 that I used. Please note, that it will not run correctly, unless you comment out all of 3.8 installation and add a RUN pip3.7 install --upgrade pip line into the Dockerfile before RUN pip3.7 install -r requirements.txt <...>.

mishanti
  • 1
  • 1
0

I was having this error while creating the Rust binary to deploy in an AWS Lambda.

I solved it by using cross as suggested in this GitHub comment.

I performed these two steps to solve the issue:

  1. Install cross: cargo install cross
  2. Compile the project using cross: cross build --release --target x86_64-unknown-linux-gnu
Julian Espinel
  • 2,586
  • 5
  • 26
  • 20