Más contenido relacionado La actualidad más candente (20) Similar a AWS의 비용 효율적 고성능기계학습(ML) 플랫폼 뛰어들기 - 윤석찬 수석 테크 에반젤리스트, AWS :: AWS Innovate 2019 (20) Más de Amazon Web Services Korea (20) AWS의 비용 효율적 고성능기계학습(ML) 플랫폼 뛰어들기 - 윤석찬 수석 테크 에반젤리스트, AWS :: AWS Innovate 20191. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 기반 비용 효율적 고성능
기계학습(ML) 플랫폼 뛰어들기
윤석찬 / AWS 테크니컬 에반젤리스트
2. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
본 세션에서 다루는 점
클라우드 기반 기계 학습 및 딥러닝 모델 훈련 방법을 알고
싶으세요?
시간과 비용을 적게 들이고 빠르게 좋은 모델을 만들고
싶으세요?
모델 훈련 및 서비스까지 자동화 하는 방법에 대한 고민이
많으세요?
추론 작업을 좀 더 빠르게 하는 방법을 알고 싶으세요?
3. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
FRAM EW O RKS
ML 프레임워크
+ 인프라
ML 서비스
AI 서비스
I NTERFACES I NFRASTRUCTURE
Am azon
SageM ak er
Amazon
Lex
C H A T B OT S
Amazon
Rekognition
Image
Amazon
Rekognition
Video
V IS ION
Amazon
Transcribe
Amazon
Polly
S P E E C H
Amazon
Comprehend
Amazon
Translate
L A N GU A GE S
P3 P3dn C5 C5n Elastic inference Inferentia AWS Greengrass
N E WN E W
Ground Truth Notebooks Algorithms + Marketplace RL Training Optimization Deployment Hosting
N E W N E W N E W N E W
Amazon
Personalize
Amazon
Forecast
V E R T IC A L
N E W N E W
Amazon
Textract
N E W
모든 개발자를 위한 인공 지능 도구 제공
4. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Deep Learning AMIs
다양한 딥러닝 프레임워크를 미리 설치하고
최적 설정을 완료한 머신 이미지(Machine Image) 제공
https://aws.amazon.com/machine-learning/amis/
Conda AMI
별도 가상 환경에 사전 설치된 딥
러닝 프레임워크 및 PIP 패키지
제공
(우분투, 아마존리눅스, 윈도용)
Base AMI
개별 딥러닝 엔진 리포지토리
또는 맞춤형 빌드를 설치
가능
(우분투, 아마존리눅스용)
AMI with source code
공유 Python 개발 환경에서 DL
엔진 및 소스 코드를 함께 제공
5. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
심지어 Deep Learning AMI는 진짜 빠릅니다!
https://aws.amazon.com/ko/blogs/machine-learning/faster-training-with-optimized-
tensorflow-1-6-on-amazon-ec2-c5-and-p3-instances/
차세대 C5 인스턴스에서 Intel AVX 및 MKL-dnn에 최적화된 TensorFlow 1.6 포함
ImageNet 데이터세트로 일반 바이너리 버전 대비 7.4배 빠른 모델 훈련 속도 제공
6. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AVX 512
72 vCPUs
“Skylake”
144 GiB memory
C5
12 Gbps to EBS
2X vCPUs
2X performance
3X throughput
2.4X memory
C4
36 vCPUs
“Haswell”
4 Gbps to EBS
60 GiB memory
Intel® AVX-512 고급 명령어
세트를 지원하므로 AI/기계 학습
또는 동영상 처리와 같은 단일 및
이중 부동 소수점 정밀도 기반
벡터 처리 작업을 효율적으로
수행
여기서 잠깐! C5 인스턴스 이란?
차세대 클라우드 가상화 환경인 Nitro를 기반한 컴퓨팅 전용 타입
7. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 P3 인스턴스 - 클라우드 기반 고성능 GPU 지원
P3 인스턴스 세부 정보
• NVIDIA Tesla V100 GPU 기반
• 40,960 CUDA cores 및 5120 Tensor Codes
• 128GB의 GPU 메모리
• 최대 8개의 GPU를 지원하는 다양한 인스턴스
타입 (p3.2xlarge, 8xlarge 및 16xlarge) 제공
1 PetaFLOPs의 컴퓨팅 성능 제공
300 GB/s GPU-to-GPU(NVLink) 네트워크 속도
만약… 인터넷에서 구매하시면?
8. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 P3 인스턴스로 GPU 클러스터를 만들어 본다면?
p3.2xlarge
= $5 per hour
(서울 리전 기준)
x 20
CPU 2,000 개 연산 능력
p3.2xlarge x 20
= $100 per hour
초당 1페타플롭스 (CPU 100개에 해당 하는 연산 능력)
9. 남는 여유 자원을 70% 할인된 가격에
모델 훈련 시에만 사용한다면
= $30 per hour
10. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
손으로 하실 필요 없어요~ 인프라를 코드로 짜면 됩니다!
$aws ec2-run-instances ami-b232d0db
--instance-count 1
--instance-type p2.8xlarge
--region us-east-1
--user-data my_data_training.sh
$aws ec2-stop-instances i-10a64379
API와 데브옵스를 통해 손쉽게 딥러닝 클러스터 구성 가능
다양한 CI/CD 기반 데브옵스 환경으로 빠른 학습 가능
11. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
여러분… 인생은 짧습니다! 시간을 아끼세요~
http://www.fast.ai/2018/08/10/fastai-diu-imagenet/
https://aws.amazon.com/blogs/machine-learning/new-speed-record-set-for-training-deep-learning-models-on-aws/
• 16개의 P3.16xlarge 인스턴스를 사용해서
18분만에 ResNet-50 모델 학습 완료 (정확도 93%)
• 저렴한 스팟 인스턴스 구매 옵션을 활용하여 $40 비용에 처리 가능
• PyTorch 기반으로 기존 DAWNBench 기록 보다 40% 빠른 속도
12. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
1
4.75
8.5
12.25
16
1 4.75 8.5 12.25 16
Speedup(x)
# GPUs
Resnet 152
Inceptin V3
Alexnet
Ideal
여기서 잠깐… 시간을 더 아끼시려면?
P2.16xlarge (8 Nvidia Tesla K80 - 16 GPUs)
Synchronous SGD (Stochastic Gradient Descent)
91%
Efficiency
88%
Efficiency
16x P2.16xlarge by AWS CloudFormation
Mounted on Amazon EFS
Apache MXNet은 GPU 갯수가 증가하더라도 이상적인 수준의 성능을 보여주는
오픈 소소 딥러닝 프레임워크로서 멀티 GPU 환경에서 탁월한 성능 제공
13. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MXNET 공부하세요…
아직은 블루오션입니다!
14. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo - 딥러닝 AMI와 스팟 인스턴스 구동하기
15. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
데이터 수집
및 저장 및
전처리
괜찮아 보이는
기계학습
알고리즘 선택
모델 훈련을
위한 서버
인프라 설정
모델 훈련
및 튜닝
(계속 반복)
최적화한
모델 배포
API 서비스
확장 및 운영
기계학습은 일반 개발자에게 여전히 복잡하고 어렵다?!
지겨운 데이터 전처리… 모델 튜닝… 될때까지 계속 반복&반복
16. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
그래서 준비했습니다… Amazon SageMaker
모델 생성
Jupyter
Notebook
기반 서비스
고성능
알고리즘
미리 제공
원클릭
데이터
훈련
모델 훈련
Hyper-
parameter
최적화
완전 관리
및 자동
스케일링
모델 배포
원클릭
모델
배포
모델 개발 및 생성, 훈련 및 서비스 배포를 위한 완전 관리 서비스
https://aws.amazon.com/ko/sagemaker
17. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SageMaker를 통한 ML 서비스 아키텍처
SageMaker
Notebooks
Training
Algorithm
SageMaker
Training
Amazon ECR
Code Commit
Code Pipeline
SageMaker
Hosting
AWS
Lambda
API
Gateway
Build Train
Deploy
static website
hosted on S3
Inference requests
Amazon S3
Amazon
Cloudfront
Web assets on
Cloudfront
18. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SageMaker 기반 ML 모델 생성 및 훈련
K-Means Clustering
Principal Component Analysis
Neural Topic Modelling
Factorization Machines
Linear Learner - Regression
XGBoost
Latent Dirichlet Allocation
Image Classification
Seq2Seq
Linear Learner - Classification
BUILT
ALGORITHMS
Caffe2, CNTK, PyTorch, Torch
IM Estimators in Spark
DEEP LEARNING
FRAMEWORKS
Bring Your Own Script
(IM builds the Container)
BRING YOUR OWN
MODEL
ML
Training
code
Fetch Training data
Save Model
Artifacts
Amazon ECR
Save Inference
Image
Amazon S3
AWS MARKETPLACE
MACHINE LEARNING
19. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SageMaker - 자동 하이퍼 파라미터 최적화(HPO) 기능
https://medium.com/datadriveninvestor/auto-model-tuning-for-keras-on-amazon-sagemaker-plant-seedling-dataset-7b591334501e
https://aws.amazon.com/blogs/machine-learning/amazon-sagemaker-automatic-model-tuning-produces-better-models-faster/
CPU (ml.m5.xlarge) 작업 시
Speed = 4 mins/epoch
Total Runtime = ~20 hours
Cost = .269 * 20 = $5.38
GPU (ml.p2.xlarge) 작업 시
Speed = 4.8 seconds/epoch
Total Runtime = ~3 hours
Cost = 1.26 * 3 = $3.78
Keras 기반 Plant Seedling
Dataset을 위한 CNN 학습 모델
(최대 150 Epoch 학습)
20. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$$$$
$$$
$$
$
Minutes Hours Days Weeks Months
Single
Machine
Distributed, with
Strong Machines
ML 모델 훈련에 대한 비용과 시간 대비 효과
21. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$$$$
$$$
$$
$
Minutes Hours Days Weeks Months
EC2 + AMI
Amazon SageMaker
On-premise
ML 모델 훈련에 대한 비용과 시간 대비 효과
22. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo – SageMaker 기반 모델 훈련하기
23. 사례. SageMaker 기반 기계 학습 구현 사례
“광고 기술 서비스 스타트업인 IGAWorks는 AWS 기반으로
일 50억 건의 디스플레이 광고 요청를 처리하는
트레이딩웍스와 22,000여개 모바일 앱이 탑재된
애드브릭스 등을 운영하고 있습니다. 광고 효율 개선 및
지속적인 최적화를 위한 기계 학습 모델 관리의 편의성과
프로덕션 적용 시간을 단축하는 Amazon SageMaker를
도입해 A.I Lab의 업무 효율성이 높아졌습니다.
기업 규모와 상관 없이
다양한 고객 활용 중!
24. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
추론 작업이 전체 기계 학습
비용의 대부분을 차지함 Inference
Training
Infrastructure
costs
추론 Inference 작업은?
Machine Learning 모델 학습은 쉽고,
빠르며, 비용 효과적으로 가능하지만…
25. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
추론 비효율의 두 가지 주요 요인 :
복잡성 및 비용
다양한 추론
케이스가 존재
탄력적인 추론이
가능해야 함
26. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
추론 작업을 더 효율적으로 하는 방법
더 작은 P2 인스턴스를 더 작은 배치 크기로 실행하는 것이 더 효과적입니다.
27. N E W !
EC2
Instance
EC2
Instance
EC2
Instance
GPU
훨씬 저렴한 비용으로 신속한 추론을 위해 Amazon EC2 인스턴스에 GPU 가속 기능 추가 (최대 75 % 절감)
Amazon
Elastic Inference
P 3 . 8 X L
P 3 P 3
P 3 P 3
Amazon
Elastic Inference
36 TOPS GPU
M5.large
Amazon
Elastic Inference
Before After
28. N E W !
고성능 처리량
낮은 대기시간
수백 TOPS 지원
다양한
데이터 타입
다양한
ML 프레임워크
INT8, FP16,
mixed precision
TensorFlow, MXNet,
PyTorch, Caffe2, ONNX
EC2 인스턴스 지원
Amazon SageMaker 지원
Amazon Elastic Inference 지원
고성능 기계 학습 추론을 위한 AWS에서 설계 한 맞춤형 칩셋
AWS Inferentia
29. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Starting at
1 TFLOPS
다양한 인스턴스
타입 활용 가능
간단한 음성 인식 및
자연어 처리 모델
Up to
32 TFLOPS
추천 엔진 또는 사기
탐지 모델
VPC 내부의 추론
탄력성 보장
360,000ResNet-50
컴퓨터 비전 사례
딥러능 모델
추론에 필요한 시간당
이미지 숫자
$0.22
시간당 비용
75%
기존 대비
비용 절감
L O W E S T C O S T
A V A I L A B L E
Amazon Elastic Inference - 확장성 및 비용
30. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
원하는 용량에 따라 가속기 타입 추가 가능
Accelerator
Type
FP32
Throughput
(TOPS)
FP16
Throughput
(TOPS)
Accelerator
Memory
(GB)
Price ($/hr)
(US)
eia1.medium 1 8 1 $0.13
eia1.large 2 16 2 $0.26
eia1.xlarge 4 32 4 $0.52
31. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
기존 GPU와 Elastic Inference와 비용 차이
0
20
40
60
80
100
120
0
10
20
30
40
50
60
70
0
20
40
60
80
100
120
140
32. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2에 활용하는 방법
VPC
Region
Availability Zone
33. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Auto Scaling groups에 적용하기
Auto Scaling group
34. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SageMaker에 적용하기
SageMaker Notebooks
SageMaker Hosted Endpoints
35. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Elastic Inference 설정 및 사용 방법
$ aws ec2 run-instances
--image-id <preconfigured_ami_id>
--instance-type <ec2_instance_type>
--key-name <key_name>
--subnet-id <subnet_id>
--security-group-ids <security_group_id
--iam-instance-profile Name=”iam_profile_name”
--elastic-inference-accelerator Type=eia1.<size>
• 일반 EC2 인스턴스 선택 후, 미리 설정된 AMI에서 원하는 EI 가속기 선택
• EI 가속기가 접속할 수 있는 VPC 엔드포인트 권한 설정 필수
36. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Elastic Inference 설정 및 사용 방법
classifier = tf.estimator.Estimator(…)
input_tensor = tf.placeholder(dtype=tf.float32,
shape=[1, 80, 128, 128, 1],
name='images_tensor’)
input_map = {'images’ : input_tensor}
classifier.export_savedmodel(model_dir,
tf.estimator.export.build_raw_serving_input_receiver_fn(input_map))
• MVCNN 모델 등 TF Estimators 포맷에 추가
• Dimensions: [batch_size , num_views , width , height , color_channels]
AmazonEI_TensorFlow_Serving_v1.11_v1 --model_name=mvcnn
--model_base_path=model_dir --port=9000
• Tensorflow Serving API를 이용하여 모델 예측 사용
37. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
맺으면서
• AWS Deep Learning AMI를 사용하시면, 기존 EC2 보다 7배 이상 빠릅니다!
• 스팟 구매 옵션으로 EC2 GPU 인스턴스를 활용하시면, 70% 저렴 합니다.
• SageMaker를 활용하시면, 모델 생성 부터 훈련, 배포 및 서비스까지 기계 학습
전 과정을 자동화 할 수 있습니다. (다음 세션에서 SageMaker의 더 많은 신기능을 살펴 보세요!)
• Elastic Inference를 활용하면, 추론 비용을 75% 이상 절감 할 수 있습니다.
38. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
마지막으로… AWS Innovate 에서는
데모 존
실제 사용 환경에서
기계학습의 사용방법을
살펴보세요
AWS 기반 머신러닝
https://aws.amazon.com/
machine-learning/
전문가에게 물어보세요
AWS 전문가가 질문에
답변드립니다
39. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
클라우드 및 인공 지능 관련 AWS 전문 교육 프로그램
클라우드 역량을 개발할 준비가 되셨다면
https://www.aws.training 을 방문하세요!
온라인 교육
AWS 전문가가 진행하는
무료 온라인 교육 과정
강의식 교육
AWS 공인 강사가 진행하는
오프라인 교육 과정
AWS 자격증
클라우드 전문성 입증을 위한
업계에서 인정 받는
AWS 공인 자격증
40. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Innovate 에 참석해주셔서 대단히 감사합니다.
저희가 준비한 내용, 어떻게 보셨나요?
더 나은 세미나를 위하여 설문을 꼭 작성해 주시기 바랍니다.
aws-korea-marketing@amazon.com
twitter.com/AWSKorea
facebook.com/amazonwebservices.ko
youtube.com/user/AWSKorea
slideshare.net/awskorea
twitch.tv/aws
AWS Innovate 에 참석해주셔서
대단히 감사합니다.