

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

# 모델 컴파일(Amazon SageMaker AI SDK)
<a name="neo-job-compilation-sagemaker-sdk"></a>

 [Amazon SageMaker AI SDK for Python](https://sagemaker.readthedocs.io/en/stable/)의 [https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html?#sagemaker.estimator.Estimator.compile_model](https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html?#sagemaker.estimator.Estimator.compile_model) API를 사용하여 훈련된 모델을 컴파일하고 특정 대상 하드웨어에 맞게 최적화할 수 있습니다. 모델 훈련 중에 사용되는 예측기 객체에서 API를 호출해야 합니다.

**참고**  
MXNet 또는 PyTorch로 모델을 컴파일할 때는 `MMS_DEFAULT_RESPONSE_TIMEOUT` 환경 변수를 `500`으로 설정해야 합니다. TensorFlow에는 환경 변수가 필요하지 않습니다.

 다음은 `trained_model_estimator` 객체를 사용하여 모델을 컴파일하는 방법의 예시입니다.

```
# Replace the value of expected_trained_model_input below and
# specify the name & shape of the expected inputs for your trained model
# in json dictionary form
expected_trained_model_input = {'data':[1, 784]}

# Replace the example target_instance_family below to your preferred target_instance_family
compiled_model = trained_model_estimator.compile_model(target_instance_family='ml_c5',
        input_shape=expected_trained_model_input,
        output_path='insert s3 output path',
        env={'MMS_DEFAULT_RESPONSE_TIMEOUT': '500'})
```

코드는 모델을 컴파일하고, 최적화된 모델을 `output_path`에 저장하고, 엔드포인트에 배포할 수 있는 SageMaker AI 모델을 만듭니다.