Problem
In a serverless project, I want to import XGBoost into a lambda written on Python. But when I'm trying to invoke the lambda, I see this error on CloudWatch:
[ERROR] XGBoostError: XGBoost Library (libxgboost.so) could not be loaded.
Likely causes:
* OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libgomp.so for UNIX-like OSes)
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['libgomp.so.1: cannot open shared object file: No such file or directory']
What I tried?
I'm running
sls deploy
on macOS so I've addeddockerizePip: true
to my serverless.ymlI tried to fix missing dependency by using custom Dockerfile:
FROM lambci/lambda:build-python3.6 RUN apt-get update && apt-get install libaio1
I also must specify library path in
dockerExtraFiles
but I have no idea where libgomp.so should be located on Linux. So, I stuck on this point.
My code
serverless.yml:
app: improve
org: kvadrug
service: testservice
provider:
name: aws
runtime: python3.8
versionFunctions: false
stage: dev
region: us-west-2
timeout: 30
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerFile: Dockerfile
zip: true
dockerizePip: true
functions:
hello:
handler: hello.hello
events:
- http:
path: hello
method: post
private: true
package.json:
{
"name": "testservice",
"version": "1.0.0",
"description": "Test service",
"dependencies": {},
"devDependencies": {
"serverless-python-requirements": "^5.1.0"
}
}
requirements.txt:
xgboost==1.0.2
libgomp1
? packages.debian.org/buster/libgomp1libomp
. Anyway, I'm not sure if it's related, because XGBoost works locally on my mac. The problem is around AWS lambda.