기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
추론 컨테이너에 대한 모델 작성 지침
이 섹션에서는 Clean Rooms ML에 대한 추론 알고리즘을 생성할 때 모델 공급자가 따라야 하는 지침을 자세히 설명합니다.
-
SageMaker AI 개발자 안내서에 설명된 대로 적절한 SageMaker AI 추론 지원 컨테이너 기본 이미지를 사용합니다. 다음 코드를 사용하면 퍼블릭 SageMaker AI 엔드포인트에서 지원되는 컨테이너 기본 이미지를 가져올 수 있습니다.
ecr_registry_endpoint='763104351884.dkr.ecr.$REGION.amazonaws.com' base_image='pytorch-inference:2.3.0-cpu-py311-ubuntu20.04-sagemaker' aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ecr_registry_endpoint docker pull $ecr_registry_endpoint/$base_image -
모델을 로컬에서 작성할 때 개발 인스턴스,의 SageMaker AI 배치 변환 AWS 계정및 Clean Rooms ML에서 로컬에서 모델을 테스트할 수 있도록 다음을 확인하세요.
-
Clean Rooms ML을 사용하면 Docker 컨테이너의
/opt/ml/model디렉터리를 통해 추론 코드에서 추론의 모델 아티팩트를 사용할 수 있습니다. -
Clean Rooms ML은 입력을 줄별로 분할하고 배치
MultiRecord전략을 사용하며 변환된 모든 레코드의 끝에 줄 바꿈 문자를 추가합니다. -
의
maxPayloadInMB에서 최대 요청 크기를 설정합니다containerExecutionParameters. 값을 지정하지 않으면 Clean Rooms ML은 6MB를 사용합니다. 입력 CSV 파일이 해당 값보다 크면 SageMaker AI는 파일을 추론 컨테이너에 대한 여러 요청으로 분할합니다. CSV 헤더 행은 해당 파일의 첫 번째 요청에만 표시되며 후속 요청은 데이터 행으로 시작됩니다. 헤더 행이 있거나 없는 요청을 수락하도록 미리 정의된 열 스키마로 추론 컨테이너를 구성합니다. 헤더 행이 있는 경우 이를 데이터 레코드로 취급하는 대신 무시합니다. 에 대한 자세한maxPayloadInMB내용은 AWS Clean Rooms ML API 참조의 InferenceContainerExecutionParameters를 참조하세요. -
모델 코드에 사용할 공동 작업자의 스키마를 기반으로 합성 또는 테스트 추론 데이터 세트를 생성할 수 있는지 확인합니다.
-
모델 알고리즘을 공동 작업과 AWS Clean Rooms 연결하기 AWS 계정 전에 SageMaker AI 배치 변환 작업을 직접 실행할 수 있는지 확인합니다.
다음 코드에는 로컬 테스트, SageMaker AI 변환 환경 테스트 및 Clean Rooms ML과 호환되는 샘플 Docker 파일이 포함되어 있습니다.
FROM763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:1.12.1-cpu-py38-ubuntu20.04-sagemaker ENV PYTHONUNBUFFERED=1 COPY serve.py /opt/ml/code/serve.py COPY inference_handler.py /opt/ml/code/inference_handler.py COPY handler_service.py /opt/ml/code/handler_service.py COPY model.py /opt/ml/code/model.py RUN chmod +x /opt/ml/code/serve.py ENTRYPOINT ["/opt/ml/code/serve.py"]
-
-
모델 변경을 완료하고 SageMaker AI 환경에서 테스트할 준비가 되면 제공된 순서대로 다음 명령을 실행합니다.
export ACCOUNT_ID=xxx export REPO_NAME=xxx export REPO_TAG=xxx export REGION=xxx docker build -t $ACCOUNT_ID.dkr.ecr.us-west-2.amazonaws.com/$REPO_NAME:$REPO_TAG # Sign into AWS $ACCOUNT_ID/ Run aws configure # Check the account and make sure it is the correct role/credentials aws sts get-caller-identity aws ecr create-repository --repository-name $REPO_NAME --region $REGION aws ecr describe-repositories --repository-name $REPO_NAME --region $REGION # Authenticate Docker aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com # Push To ECR Repository docker push $ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com$REPO_NAME:$REPO_TAG # Create Sagemaker Model # Configure the create_model.json with # 1. Primary container - # a. ModelDataUrl - S3 Uri of the model.tar from your training job aws sagemaker create-model --cli-input-json file://create_model.json --region $REGION # Create Sagemaker Transform Job # Configure the transform_job.json with # 1. Model created in the step above # 2. MultiRecord batch strategy # 3. Line SplitType for TransformInput # 4. AssembleWith Line for TransformOutput aws sagemaker create-transform-job --cli-input-json file://transform_job.json --region $REGIONSageMaker AI 작업이 완료되고 배치 변환에 만족하면 AWS Clean Rooms ML에 Amazon ECR 레지스트리를 등록할 수 있습니다.
CreateConfiguredModelAlgorithm작업을 사용하여 모델 알고리즘을 등록하고CreateConfiguredModelAlgorithmAssociation를 사용하여 이를 공동 작업에 연결합니다.