Failed to launch app from custom SageMaker image: ResourceNotFoundError with UID/GID in AppImageConfig

0

I'm trying to create a custom SageMaker image and launch a kernel from it, because I want to see if I can use black, the python code formatter, in SageMaker Studio via a custom SageMaker image.

So far, I've been able to attach the image to the SageMaker domain and start launching the kernel from the custom image, following these steps. However, as soon as the notebook opens, it displays this error in the notebook:

Failed to launch app [black-conda-ml-t3-medium-7123fdb901f81ab5]. ResourceNotFoundError: SageMaker is unable to launch the app using the image [123456789012.dkr.ecr.us-east-1.amazonaws.com/conda-sample@sha256:12345]. Ensure that the UID/GID provided in the AppImageConfig matches the default UID/GID defined in the image. (Context: RequestId: 21234b0f568, TimeStamp: 1677767016.2990377, Date: Thu Mar 2 14:23:36 2023)

Here are the relevant code snippets: Dockerfile:

FROM continuumio/miniconda3:4.9.2

COPY environment.yml .
RUN conda env update -f environment.yml --prune

environment.yml:

name: base
channels:
 - conda-forge
dependencies:
 - python=3.9
 - numpy
 - awscli
 - boto3
 - ipykernel
 - black

and AppImageConfig:

{
    "AppImageConfigName": "conda-env-kernel-config",
    "KernelGatewayImageConfig": {
        "KernelSpecs": [
            {
                "Name": "python3",
                "DisplayName": "Python [conda env: myenv]"
            }
        ],
        "FileSystemConfig": {
            "MountPath": "/root",
            "DefaultUid": 0,
            "DefaultGid": 0
        }
    }
}

I tried following this troubleshooting guide, but it doesn't seem to address my issues because all of the diagnostics worked alright. For example, when I ran id -u and id -g inside my local container, the results 0 and 0 lined up with the AppImageConfig settings of "DefaultUid": 0, "DefaultGid": 0.

AWS
asked a year ago1327 views
1 Answer
0

It's not enough to have the AppImageConfig locally and only push the built image to ECR -- you also need to push the AppImageConfig using the following command:

aws sagemaker create-app-image-config \
    --cli-input-json file://app-image-config-input.json

And then use that when you're attaching the custom image to the SageMaker domain.

If you're doing that in the Console, then you don't actually use the AppImageConfig file itself -- you just enter the info from it into the create image dialog:

        "MountPath": "/root",
        "DefaultUid": 0,
        "DefaultGid": 0
        "Name": "python3",
        "DisplayName": "Python [conda env: myenv]"
AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions