Cant get dlib to run on AWS Lambda when compiling with OpenBLAS.
See original GitHub issueHowdy!
I got the library working as a AWS Lambda function. I compiled it using their amazonlinux docker container, but as before the performance is really bad without the OpenBLAS support so i installed it using their yum package manager. Tried using blas, openblas, blas-devel and openblas-devel, openblas-static and also lapack and lapack-devel, but I keep ending up with these kind of errors:
libblas.so.3: cannot open shared object file: No such file or directory
or
libopenblas.so.0: cannot open shared object file: No such file or directory
when building the library (iside the amazonlinux docker container) i get this message at the end that makes me believe that the dependencies are not built statically:
Linking CXX shared library libdlib.so
[100%] Built target dlib_shared
or could it be some kind of path issue ?
the libpng and libX11 libraries doesn’t seem to have any issues, and i don’t really know the difference as the those are also installed using yum as the packages libX11-devel and libpng-devel.
feels like i somehow need to make sure that the openblas library is packaged together with dlib in my node_modules directory or some other way accessible when running in the lambda environment.
any ideas?
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (9 by maintainers)
Top GitHub Comments
Thanks @justadudewhohacks and @bobmoff for all the info in this issue. After a lot of false starts I was able to get it working on Lambda with OpenBlas. Below I’ve listed some of the key things that caused me trouble during the process so hopefully other people don’t waste time on these issues.
Compile on EC2 using the correct Amazon Linux AMI that Amazon uses for Lambda. A link to the AMI should be on this page https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
Compile on EC2 using the exact same version of Node that you will run on Lambda. I used v8.10.0
Despite Amazon stating that there is a 50MB limit on the total zip size, I was able to upload zip files that are 170MB. (It’s possible that I applied for the limit on my account to be raised in the past, but I don’t remember doing that)
Take care when zipping up the deployment package. Using the standard MacOS Finder will not work as it places everything in a folder. You need to use the command line from within the folder (e.g.
zip -r ../face-detection-lambda.zip *
)Copy the required shared libraries from EC2 (in my case
libopenblas.so.0
andlibgfortran.so.3
) into the root folder of your deployment package, and add the following command to the start of the lambda function so lambda knows how to access them.process.env["PATH"] = process.env["PATH"] + ":" + process.env["LAMBDA_TASK_ROOT"]
@bobmoff Thank you for creating https://github.com/bobmoff/face-recognition.js-as-a-function
I will test on google cloud function and AWS and get back to you with my findings. If I make any progress I will create a repository and send it over.