作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题
在无服务器项目中,我想将 XGBoost 导入到用 Python 编写的 lambda 中。但是当我尝试调用 lambda 时,我在 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']
sls deploy
在 macOS 上,我添加了 dockerizePip: true
到我的 serverless.yml FROM lambci/lambda:build-python3.6
RUN apt-get update && apt-get install libaio1
dockerExtraFiles
中的库路径但我不知道 libgomp.so 应该在 Linux 上的什么位置。所以,我坚持这一点。 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
{
"name": "testservice",
"version": "1.0.0",
"description": "Test service",
"dependencies": {},
"devDependencies": {
"serverless-python-requirements": "^5.1.0"
}
}
xgboost==1.0.2
最佳答案
工作配置 - Python 3.7
在 Mojave 10.14.6 (18G4032) 和 Docker v2.1.0.2 (37877) 上测试。
脚步:
sls requirements clean
rm -Rf ~/Library/Caches/serverless-python-requirements/
sls deploy
xgboost==1.0.2
service: xgboost
provider:
name: aws
timeout:60
runtime: python3.7
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
zip: true
dockerizePip: non-linux
dockerExtraFiles:
- /usr/lib64/libgomp.so.1
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: post
private: true
try:
import unzip_requirements
except ImportError:
pass
import sys
import glob
import os
def hello(event, context):
pkgdir = '/tmp/sls-py-req/'
print("-------- Sys Path --------")
for p in sys.path:
print(p)
if os.path.exists(pkgdir):
print("-------- Pkg Dir ----------")
os.chdir(pkgdir)
for file in glob.glob("*"):
print(file)
print("-------- Var Task ----------")
os.chdir("/var/task")
for file in glob.glob("*"):
print(file)
try:
import xgboost as xgb
print(xgb)
except Exception as ex:
template = "An exception of type {0} occurred. Arguments:\n{1!r}"
message = template.format(type(ex).__name__, ex.args)
print(message)
return True
sls requirements clean
rm -Rf ~/Library/Caches/serverless-python-requirements/
sls package
cp .serverless/requirements/libgomp.so.1 ./
sls deploy
docker run --rm -ti --entrypoint /bin/sh -u 0 lambci/lambda\:build-python3.8
find / -name libgomp.so.1
关于python - 无法加载 XGBoost 库 (libxgboost.so),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61717991/
问题 在无服务器项目中,我想将 XGBoost 导入到用 Python 编写的 lambda 中。但是当我尝试调用 lambda 时,我在 CloudWatch 上看到了这个错误: [ERROR] X
我是一名优秀的程序员,十分优秀!