I get errors when I use a custom image to build my Amazon SageMaker Studio environment, and I want to know how to resolve them.
Resolution
Make sure that the AmazonSageMakerFullAccess policy is attached to your AWS Identity and Access Management (IAM) user or role.
If you get errors when you import your custom image, then verify that you correctly configured the container image build.
When you're building the Dockerfile, use the following configurations:
- SageMaker Studio supports only a specific combination of DefaultUID and DefaultGID. For a user without permissions, set DefaultUID to 1000 and DefaultGID to 100. For the root user, set both values to 0.
- Don't use the opt/.sagemakerinternal and opt/ml reserved directories.
- Be sure that the Name value for KernelSpec in the file matches the Name value for the associated image in the app-image-config-input.json configuration file.
Example Dockerfile that installs Python packages and sets the scope to users without permissions:
FROM public.ecr.aws/amazonlinux/amazonlinux:2
ARG NB_USER="sagemaker-user"
ARG NB_UID="1000"
ARG NB_GID="100"
RUN \
yum install --assumeyes python3 shadow-utils && \
useradd --create-home --shell /bin/bash --gid "${NB_GID}" --uid ${NB_UID} ${NB_USER} && \
yum clean all && \
python3 -m pip install ipykernel && \
python3 -m ipykernel install
USER ${NB_UID}
If you continue to get an error message when you're creating or launching the image, then review the SageMaker Studio logs in Amazon CloudWatch Logs. You can find the error messages in the /aws/sagemaker/studio log group and $domainID/$userProfileName/KernelGateway/$appName log stream.
Related information
Custom SageMaker image specifications
Create a custom SageMaker image