opencv_aws_lambda icon indicating copy to clipboard operation
opencv_aws_lambda copied to clipboard

Segmentation fault in AWS Lambda call

Open dioh opened this issue 4 years ago • 2 comments

When using python-opencv-headless for runtime python 3.8 will throw segmentation fault on invocation. Do you know why is this happening?

Dockerfile:

`FROM amazonlinux

WORKDIR / RUN yum update -y

Install Python 3.8

RUN yum install gcc openssl-devel bzip2-devel libffi-devel wget tar gzip make -y RUN wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz RUN tar -xzvf Python-3.7.0.tgz WORKDIR /Python-3.7.0 RUN ./configure --enable-optimizations RUN make install

Install Python 3.7

RUN yum install python3 zip -y

Install Python packages

RUN mkdir /packages RUN echo "opencv-python-headless" >> /packages/requirements.txt RUN mkdir -p /packages/opencv-python-3.7/python/lib/python3.7/site-packages

RUN mkdir -p /packages/opencv-python-3.8/python/lib/python3.8/site-packages

RUN echo "numpy" >> /packages/requirements.txt RUN echo "pdf2image" >> /packages/requirements.txt RUN pip3.7 install pip --upgrade RUN pip3.7 install -r /packages/requirements.txt -t /packages/opencv-python-3.7/python/lib/python3.7/site-packages

Create zip files for Lambda Layer deployment

WORKDIR /packages/opencv-python-3.7/ RUN zip -r9 /packages/cv2-python37.zip . WORKDIR /packages/

RUN rm -rf /packages/opencv-python-3.7/

`

dioh avatar Oct 30 '20 17:10 dioh

What's the exact error you're getting? You're just getting a seg fault?

amirhmk avatar Dec 01 '20 01:12 amirhmk

Using this package on Serverless helped me streamline this whole process and reduce the package size as well. Would definitely recommend checking it out. Make sure to leave the strip flag to false

Serverless python-requirements plugin

amirhmk avatar Dec 03 '20 00:12 amirhmk