0

I am running fastapi on lambda and I got Lambda error which I believe related to moviepy and opencv. The error text is at the bottom.

My main.py (the part where the error is triggered)

...
from moviepy.editor import VideoFileClip
...

My dockerfile

FROM public.ecr.aws/lambda/python:3.8-x86_64

ADD app app

COPY ./requirements.txt ./requirements.txt

RUN yum -y install mesa-libGL libsndfile
RUN pip install -r ./requirements.txt

ENV NUMBA_CACHE_DIR=/tmp
ENV MPLCONFIGDIR=/tmp

CMD ["app.main.handler"]

My requirements.txt

fastapi==0.89.1
librosa==0.9.2
mangum==0.15.1
mediapipe==0.8.9.1
moviepy==1.0.3
numpy==1.23.5
opencv-python-headless==4.6.0.66
pandas==1.2.1
pydub==0.25.1
Pyrebase4==4.5.0
requests==2.28.1
tensorflow==2.10.0
uvicorn[standard]==0.17.6

The error thrown on Lambda

RequestId: ba8f8500-8338-48c5-b908-8b8f546646f8 Error: Runtime exited with error: signal: segmentation fault
Runtime.ExitError

The error thrown is not helpful at all so I'm having a hard time identifying the cause here. It's kinda weird because few months back, everything run perfectly. only recently the code is failing. What might be the solution for this?

Apezzz
  • 95
  • 2
  • 8
  • "segmentation fault" is nothing to go on. please figure out how to get useful debugging information out of this system. AWS lambda surely provides for that? – Christoph Rackwitz Jan 15 '23 at 21:09
  • That's the thing, the instance automatically killed before any error could be prompted. – Apezzz Jan 16 '23 at 04:17
  • IIRC you can try to run the image locally. Does this give any additional insight? – Polpetta Jan 16 '23 at 16:04
  • Yup you can and I did try. I tried running docker as it is (like if you want to deploy on a normal server) and running it as a Lambda docker. The first one works totally fine. The second one throws the same error as I mentioned. – Apezzz Jan 17 '23 at 18:17
  • Please confirm if you are getting this error on your local machine or on the aws lambda function – ekibet Jul 09 '23 at 13:19
  • It throws error running in docker Lambda environment (in both local and AWS Lambda function) – Apezzz Jul 12 '23 at 00:53

0 Answers0