gpt4 book ai didi

python - AWS sagemaker 错误 - AttributeError : 'NoneType' object has no attribute 'startswith'

转载 作者:行者123 更新时间:2023-12-02 19:47:58 50 4
gpt4 key购买 nike

据此 - How to use a pretrained model from s3 to predict some data? ,我试图使用现有模型创建端点,但遇到以下错误 -

    Traceback (most recent call last):
File "/miniconda3/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 55, in handle
self.handle_request(listener_name, req, client, addr)
File "/miniconda3/lib/python3.7/site-packages/gunicorn/workers/ggevent.py", line 143, in handle_request
super().handle_request(listener_name, req, sock, addr)
File "/miniconda3/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 106, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/miniconda3/lib/python3.7/site-packages/sagemaker_sklearn_container/serving.py", line 124, in main
serving_env.module_dir)
File "/miniconda3/lib/python3.7/site-packages/sagemaker_sklearn_container/serving.py", line 101, in import_module
user_module = importlib.import_module(module_name)
File "/miniconda3/lib/python3.7/importlib/__init__.py", line 118, in import_module
if name.startswith('.'):
根据 Problem deploying the best estimator gotten with sagemaker.estimator.Estimator (w/ sklearn custom image) , https://forums.aws.amazon.com/thread.jspa?threadID=313838 ,我正在使用正确的环境变量(以及 SAGEMAKER_DEFAULT_INVOCATIONS_ACCEPTSAGEMAKER_PROGRAMSAGEMAKER_SUBMIT_DIRECTORY ),但不知何故,在创建端点时运行状况检查失败。
我通过 AWS 控制台尝试了类似的事情,它的工作令人惊讶。
有没有办法通过代码来解决这个问题?
我的代码片段:
trainedmodel = sagemaker.model.Model(
model_data='s3://my-bucket/my-key/output/model.tar.gz',
image='my-image',
env={"SAGEMAKER_DEFAULT_INVOCATIONS_ACCEPT": "text/csv",
"SAGEMAKER_USE_NGINX": "True",
"SAGEMAKER_WORKER_CLASS_TYPE": "gevent",
"SAGEMAKER_KEEP_ALIVE_SEC": "60",
"SAGEMAKER_CONTAINER_LOG_LEVEL": "20",
"SAGEMAKER_ENABLE_CLOUDWATCH_METRICS": "false",
"SAGEMAKER_PROGRAM": "my-script.py",
"SAGEMAKER_REGION": "us-east-1",
"SAGEMAKER_SUBMIT_DIRECTORY": "s3://my-bucket/my-key/source/sourcedir.tar.gz"
},
role=role)

trainedmodel.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge', endpoint_name = 'my-endpoint')

最佳答案

对于其他登陆这里的人,我在从 ModelPackage 创建 sklearn 模型时遇到了类似的问题。
尝试创建端点时端点日志中的错误消息:

AttributeError: 'NoneType' object has no attribute 'startswith'


在定义模型包时解决了以下问题:
  • 环境变量 SAGEMAKER_SUBMIT_DIRECTORY应设置为容器上的目录,通常为'/opt/ml/model/'
  • SAGEMAKER_PROGRAM应设置为服务脚本的名称,例如'sagemaker_serve.py'

  • 这些在“容器”部分中每个条目的“环境”部分下指定。

    关于python - AWS sagemaker 错误 - AttributeError : 'NoneType' object has no attribute 'startswith' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62489539/

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