기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
모델 컴파일(AWS Command Line Interface)
이 섹션에서는 AWS Command Line Interface (CLI)를 사용하여 기계 학습 모델에 대한 Amazon SageMaker Neo 컴파일 작업을 관리하는 방법을 보여줍니다. 컴파일 작업을 생성, 설명, 중지 및 나열할 수 있습니다.
컴파일 작업 생성
CreateCompilationJob API 작업을 통해 데이터 입력 형식, 모델을 저장할 S3 버킷, 컴파일된 모델을 저장할 S3 버킷, 대상 하드웨어 디바이스 또는 플랫폼을 지정할 수 있습니다.
다음 표는 대상이 디바이스인지 플랫폼인지에 따라 CreateCompilationJob
API를 구성하는 방법을 보여줍니다.
- Device Example
-
{
"CompilationJobName": "neo-compilation-job-demo
",
"RoleArn": "arn:aws:iam::<your-account>
:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss
",
"InputConfig": {
"S3Uri": "s3://<your-bucket>
/sagemaker/neo-compilation-job-demo-data/train
",
"DataInputConfig": "{'data': [1,3,1024,1024]}
",
"Framework": "MXNET
"
},
"OutputConfig": {
"S3OutputLocation": "s3://<your-bucket>
/sagemaker/neo-compilation-job-demo-data/compile
",
# A target device specification example for a ml_c5 instance family
"TargetDevice": "ml_c5
"
},
"StoppingCondition": {
"MaxRuntimeInSeconds": 300
}
}
PyTorch 프레임워크를 사용하여 모델을 훈련시켰고 대상 디바이스가 ml_*
대상인 경우 FrameworkVersion
필드에서 사용한 프레임워크 버전을 선택적으로 지정할 수 있습니다.
{
"CompilationJobName": "neo-compilation-job-demo",
"RoleArn": "arn:aws:iam::<your-account>
:role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss",
"InputConfig": {
"S3Uri": "s3://<your-bucket>
/sagemaker/neo-compilation-job-demo-data/train",
"DataInputConfig": "{'data': [1,3,1024,1024]}",
"Framework": "PYTORCH",
"FrameworkVersion": "1.6"
},
"OutputConfig": {
"S3OutputLocation": "s3://<your-bucket>
/sagemaker/neo-compilation-job-demo-data/compile",
# A target device specification example for a ml_c5 instance family
"TargetDevice": "ml_c5",
# When compiling for ml_* instances using PyTorch framework, use the "CompilerOptions" field in
# OutputConfig to provide the correct data type ("dtype") of the model’s input. Default assumed is "float32"
"CompilerOptions": "{'dtype': 'long'}"
},
"StoppingCondition": {
"MaxRuntimeInSeconds": 300
}
}
-
PyTorch 2.0 이상 버전을 사용하여 모델을 저장한 경우 DataInputConfig
필드는 선택 사항입니다. SageMaker AI Neo는 PyTorch로 생성한 모델 정의 파일에서 입력 구성을 가져옵니다. 정의 파일을 생성하는 방법에 대한 자세한 내용은 SageMaker AI Neo용 모델 저장 아래의 PyTorch 섹션을 참조하세요. SageMaker
-
이 API 필드는 PyTorch에서만 지원됩니다.
- Platform Example
-
{
"CompilationJobName": "neo-test-compilation-job
",
"RoleArn": "arn:aws:iam::<your-account>:
role/service-role/AmazonSageMaker-ExecutionRole-yyyymmddThhmmss
",
"InputConfig": {
"S3Uri": "s3://<your-bucket>
/sagemaker/neo-compilation-job-demo-data/train
",
"DataInputConfig": "{'data': [1,3,1024,1024]}
",
"Framework": "MXNET
"
},
"OutputConfig": {
"S3OutputLocation": "s3://<your-bucket>
/sagemaker/neo-compilation-job-demo-data/compile
",
# A target platform configuration example for a p3.2xlarge instance
"TargetPlatform": {
"Os": "LINUX
",
"Arch": "X86_64
",
"Accelerator": "NVIDIA
"
},
"CompilerOptions": "{'cuda-ver': '10.0', 'trt-ver': '6.0.1', 'gpu-code': 'sm_70'
}"
},
"StoppingCondition": {
"MaxRuntimeInSeconds": 300
}
}
OutputConfig
API 연산의 경우 TargetDevice
및 TargetPlatform
API 연산은 상호 배타적입니다. 두 옵션 중 하나를 선택해야 합니다.
프레임워크에 따른 DataInputConfig
의 JSON 문자열 예제를 찾으려면 Neo에 필요한 입력 데이터 형태를 참조하세요.
구성 설정에 대한 자세한 내용은 SageMaker API 참조에서 InputConfig, OutputConfig 및 TargetPlatform API 연산을 참조하세요.
JSON 파일을 구성한 후 다음 명령을 실행하여 컴파일 작업을 생성합니다.
aws sagemaker create-compilation-job \
--cli-input-json file://job.json \
--region us-west-2
# You should get CompilationJobArn
다음 명령어를 실행하여 컴파일 작업을 설명합니다.
aws sagemaker describe-compilation-job \
--compilation-job-name $JOB_NM \
--region us-west-2
다음 명령을 실행하여 컴파일 작업을 중지합니다.
aws sagemaker stop-compilation-job \
--compilation-job-name $JOB_NM \
--region us-west-2
# There is no output for compilation-job operation
다음 명령을 실행하여 컴파일 작업을 나열합니다.
aws sagemaker list-compilation-jobs \
--region us-west-2