【问题标题】:SageMaker gives CannotStartContainerError although I specified an entrypointSageMaker 给出了 CannotStartContainerError 尽管我指定了一个入口点
【发布时间】:2020-07-12 03:56:22
【问题描述】:

我想使用 SageMaker 训练自定义 ML 模型。该模型是用 Python 编写的,应该以 Docker 映像的形式发送到 SageMaker。这是我的 Dockerfile 的简化版本(模型位于 train.py 文件中):

FROM amazonlinux:latest

# Install Python 3
RUN yum -y update && yum install -y python3-pip python3-devel gcc && yum clean all

# Install sagemaker-containers (the official SageMaker utils package)
RUN pip3 install --target=/usr/local/lib/python3.7/site-packages sagemaker-containers && rm -rf /root/.cache

# Bring the script with the model to the image 
COPY train.py /opt/ml/code/train.py

ENV SAGEMAKER_PROGRAM train.py

现在,如果我将此图像初始化为 SageMaker 估算器,然后在此估算器上运行 fit 方法,则会收到以下错误:

“算法错误:CannotStartContainerError。请确保容器可以使用 'docker run train' 运行。”

换句话说:SageMaker 无法进入容器并运行 train.py 文件。但为什么?我在docs of the sagemaker-containers package 中推荐使用ENV SAGEMAKER_PROGRAM train.py 指定入口点的方式(请参阅“如何在容器内执行脚本”)。

【问题讨论】:

    标签: python image docker amazon-sagemaker amazon-linux-2


    【解决方案1】:

    我在the AWS docs 中发现了一个提示并想出了这个解决方案:

    ENTRYPOINT ["python3.7", "/opt/ml/code/train.py"]
    

    有了这个容器will run as an executable

    【讨论】:

      【解决方案2】:

      我在使用“sagemaker-training”工具包时遇到了同样的错误。 尝试在“pip install”命令中指定软件包版本。它解决了我的问题。不知道为什么......

      【讨论】:

        猜你喜欢
        • 2017-01-24
        • 1970-01-01
        • 2021-12-23
        • 1970-01-01
        • 2013-06-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多