

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 실시간 추론을 위한 Autopilot 모델 배포
<a name="text-classification-deploy-models"></a>

Amazon SageMaker Autopilot모델을 훈련시킨 후 엔드포인트를 설정하고 대화형 방식으로 예측을 획득할 수 있습니다. 다음 섹션에서는 모델을 SageMaker AI 실시간 추론 엔드포인트에 배포하여 모델에서 예측을 가져오는 단계를 설명합니다.

## 실시간 추론
<a name="autopilot-deploy-models-text-image-classification-realtime"></a>

실시간 추론은 실시간, 대화형, 짧은 지연 시간이 요구되는 추론 워크로드에 적합합니다. 이 섹션에서는 실시간 추론을 사용하여 모델에서 대화형 방식으로 예측을 얻는 방법을 보여줍니다.

SageMaker API를 사용하여 다음과 같이 Autopilot 실험에서 최상의 검증 지표를 생성한 모델을 수동으로 배포할 수 있습니다.

또는 Autopilot 실험을 생성할 때 자동 배포 옵션을 선택할 수도 있습니다. 모델 자동 배포 설정에 대한 자세한 내용은 `[CreateAutoMLJobV2](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateAutoMLJobV2.html#API_CreateAutoMLJobV2_RequestParameters)`의 요청 파라미터에서 `[ModelDeployConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateAutoMLJobV2.html#sagemaker-CreateAutoMLJobV2-request-ModelDeployConfig)`를 참조하세요. 그러면 엔드포인트가 자동으로 생성됩니다.

**참고**  
불필요한 요금이 발생하지 않도록 모델 배포에서 생성된 불필요한 엔드포인트와 리소스를 삭제할 수 있습니다. 리전별 인스턴스 요금에 대한 자세한 내용은 [Amazon SageMaker 요금](https://aws.amazon.com/sagemaker/pricing/)을 참고하세요.

1. **후보 컨테이너 정의 획득**

   [추론 컨테이너](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_AutoMLCandidate.html#sagemaker-Type-AutoMLCandidate-InferenceContainers)에서 후보 컨테이너 정의를 가져옵니다. 추론을 위한 컨테이너 정의는 훈련된 SageMaker AI 모델을 배포하고 실행하여 예측하도록 설계된 컨테이너식 환경을 말합니다.

   다음 AWS CLI 명령 예제에서는 [DescribeAutoMLJobV2](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeAutoMLJobV2.html) API를 사용하여 최상의 모델 후보에 대한 후보 정의를 가져옵니다.

   ```
   aws sagemaker describe-auto-ml-job-v2 --auto-ml-job-name job-name --region region
   ```

1. **후보 나열**

   다음 AWS CLI 명령 예제에서는 [ListCandidatesForAutoMLJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ListCandidatesForAutoMLJob.html) API를 사용하여 모든 모델 후보를 나열합니다.

   ```
   aws sagemaker list-candidates-for-auto-ml-job --auto-ml-job-name <job-name> --region <region>
   ```

1. **SageMaker AI 모델 만들기**

   이전 단계의 컨테이너 정의와 선택한 후보를 사용하여 [CreateModel](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html) API를 이용해 SageMaker AI 모델을 만듭니다. 다음 AWS CLI 명령을 예제로 참조하십시오.

   ```
   aws sagemaker create-model --model-name '<your-candidate-name>' \
                       --containers ['<container-definition1>, <container-definition2>, <container-definition3>]' \
                       --execution-role-arn '<execution-role-arn>' --region '<region>
   ```

1. **엔드포인트 구성 생성**

   다음 AWS CLI 명령 예제에서는 [CreateEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpointConfig.html) API를 사용하여 엔드포인트 구성을 생성합니다.

   ```
   aws sagemaker create-endpoint-config --endpoint-config-name '<your-endpoint-config-name>' \
                       --production-variants '<list-of-production-variants>' \
                       --region '<region>'
   ```

1. **엔드포인트 생성** 

   다음 AWS CLI 예제에서는 [CreateEndpoint](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html) API를 사용하여 엔드포인트를 생성합니다.

   ```
   aws sagemaker create-endpoint --endpoint-name '<your-endpoint-name>' \
                       --endpoint-config-name '<endpoint-config-name-you-just-created>' \
                       --region '<region>'
   ```

   [DescribeEndpoint](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DescribeEndpoint.html) API를 사용하여 엔드포인트 배포 진행 상황을 확인합니다. 다음 AWS CLI 명령을 예제로 참조하십시오.

   ```
   aws sagemaker describe-endpoint —endpoint-name '<endpoint-name>' —region <region>
   ```

   `EndpointStatus`가 `InService`로 변경되면 엔드포인트를 실시간 추론에 사용할 수 있습니다.

1. **API 엔드포인트 호출** 

   다음 명령 구조는 실시간 추론을 위해 엔드포인트를 간접적으로 호출합니다.

   ```
   aws sagemaker invoke-endpoint --endpoint-name '<endpoint-name>' \ 
                     --region '<region>' --body '<your-data>' [--content-type] '<content-type>' <outfile>
   ```