SageMaker Python SDK 속도 초과 및 조절 예외를 해결하려면 어떻게 해야 합니까?
최종 업데이트 날짜: 2020년 10월 12일
Amazon SageMaker Python SDK를 사용할 때 “botocore.exceptions.ClientError: 오류 발생(ThrottlingException)”과 같은 조절 오류를 해결하려면 어떻게 해야 합니까?
간략한 설명
사용자 지정 재시도 구성을 사용한 SageMaker boto3 클라이언트를 SageMaker Python SDK 클라이언트에 추가합니다.
해결 방법
1. 사용자 지정 재시도 구성을 사용하여 SageMaker boto3 클라이언트를 생성합니다. 예:
import boto3
from botocore.config import Config
sm_boto = boto3.client('sagemaker', config=Config(connect_timeout=5, read_timeout=60, retries={'max_attempts': 20}))
print(sm_boto.meta.config.retries)
2. 이전 단계에서 생성한 boto3 클라이언트를 사용하여 SageMaker Python SDK 클라이언트를 생성합니다. 예:
import sagemaker
sagemaker_session = sagemaker.Session(sagemaker_client = sm_boto)
region = sagemaker_session.boto_session.region_name
print(sagemaker_session.sagemaker_client.meta.config.retries)
3. SageMaker Python SDK에서 여러 개의 요청을 사용하여 SageMaker API를 테스트합니다. 예:
import multiprocessing
def worker(TrainingJobName):
print(sagemaker_session.sagemaker_client
.describe_training_job(TrainingJobName=TrainingJobName)
['TrainingJobName'])
return
if __name__ == '__main__':
jobs = []
TrainingJobName = 'your-job-name'
for i in range(10):
p = multiprocessing.Process(target=worker, args=(TrainingJobName,))
jobs.append(p)
p.start()
4. sagemaker_session 파라미터를 사용하여 sagemaker.estimator.Estimator 클래스의 인스턴스를 생성합니다. 예:
estimator = sagemaker.estimator.Estimator(container,
role,
train_instance_count=1,
train_instance_type='ml.c4.4xlarge',
train_volume_size = 30,
train_max_run = 360000,
input_mode= 'File',
output_path=s3_output_location,
sagemaker_session=sagemaker_session )
5. 이전 단계에서 생성한 예측기에서 훈련 작업을 실행하여 이 재시도 구성으로 조절 예외가 해결되는지 확인합니다.
estimator.fit()