gpt4 book ai didi

python - 使用 zappa 部署到 AWS Lambda 时,spaCy 抛出 OSError

转载 作者:太空宇宙 更新时间:2023-11-03 11:41:06 26 4
gpt4 key购买 nike

将 Python spaCy 应用程序部署到 AWS Lambda 时,我在部署中遇到以下错误(见下文)。为什么要使用 zappa 进行部署? zip 文件压缩后为 125MB,因此从 aws-cli 直接上传在空间上失败,并且传输到 S3 也失败,因为未压缩的文件超过 250MB。

我的程序本身没有进行任何多线程或多处理,它只使用 spaCy 2.0。我在 EC2 AWS Linux t2.medium 上构建和部署。从 spaCy AWS Lambda 函数获得往返答案的确切步骤是什么?

故障跟踪如下:

[1520570028387] Failed to find library...right filename?
[1520570029826] [Errno 38] Function not implemented: OSError
Traceback (most recent call last):
File "/var/task/handler.py", line 509, in lambda_handler
return LambdaHandler.lambda_handler(event, context)
File "/var/task/handler.py", line 237, in lambda_handler
handler = cls()
File "/var/task/handler.py", line 129, in __init__
self.app_module = importlib.import_module(self.settings.APP_MODULE)
File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/tmp/spaciness/front.py", line 1, in <module>
import spacy
File "/tmp/spaciness/spacy/__init__.py", line 4, in <module>
from .cli.info import info as cli_info
File "/tmp/spaciness/spacy/cli/__init__.py", line 1, in <module>
from .download import download
File "/tmp/spaciness/spacy/cli/download.py", line 10, in <module>
from .link import link
File "/tmp/spaciness/spacy/cli/link.py", line 7, in <module>
from ..compat import symlink_to, path2str
File "/tmp/spaciness/spacy/compat.py", line 11, in <module>
from thinc.neural.util import copy_array
File "/tmp/spaciness/thinc/neural/__init__.py", line 1, in <module>
from ._classes.model import Model
File "/tmp/spaciness/thinc/neural/_classes/model.py", line 12, in <module>
from ..train import Trainer
File "/tmp/spaciness/thinc/neural/train.py", line 7, in <module>
from tqdm import tqdm
File "/tmp/spaciness/tqdm/__init__.py", line 1, in <module>
from ._tqdm import tqdm
File "/tmp/spaciness/tqdm/_tqdm.py", line 53, in <module>
mp_lock = mp.Lock() # multiprocessing lock
File "/var/lang/lib/python3.6/multiprocessing/context.py", line 67, in Lock
return Lock(ctx=self.get_context())
File "/var/lang/lib/python3.6/multiprocessing/synchronize.py", line 163, in __init__
SemLock.__init__(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.6/multiprocessing/synchronize.py", line 60, in __init__
unlink_now)
OSError: [Errno 38] Function not implemented

最佳答案

我可以通过以下步骤解决问题:

  1. 增加 zappa_settings.json 中 lambda 函数的内存大小:

    { “开发”:{

        "memory_size": 3008,
    }

  2. 我不得不使用更新版本的 tqdm。默认情况下,版本 4.19 存在以下问题,如下所述:https://github.com/tqdm/tqdm/issues/466

所描述的问题已在较新版本中得到修复。它只是将 tqdm 添加到我的 requirements.txt 并执行包的 pip 升级:

pip install -U tqdm

当我执行 zappa deploy dev 时,我现在收到以下消息:

(tqdm 4.32.1 (/var/task/ve/lib/python3.6/site-packages), Requirement.parse('tqdm==4.19.1'), {'zappa'})

tqdm 4.19.1 是 zappa 的默认版本,tqdm 4.32.1 是包含修复的新版本。

关于python - 使用 zappa 部署到 AWS Lambda 时,spaCy 抛出 OSError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49186886/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com