More Related Content Similar to Amazon EKS를 활용한 기계 학습 모델 서버 확장하기 - 유홍근, LG전자 :: AWS Summit Seoul 2019 (20) More from Amazon Web Services Korea (20) Amazon EKS를 활용한 기계 학습 모델 서버 확장하기 - 유홍근, LG전자 :: AWS Summit Seoul 20191. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon EKS를 활용한
기계학습 모델 서버 확장하기
유홍근
선임 연구원
LG전자
2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
오늘의 주제
손쉽게 기계학습 훈련을 확장해 봅시다
3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
저는요
커피고래
술 좋아하면 술고래,
커피 좋아하면 커피고래
https://coffeewhale.com
4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
오늘 다루지 않을 내용
쿠버네티스 자체에 대한 이야기
5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
오늘 다루지 않을 내용
모델링에 대한 이야기
6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
발표 내용
누구나
손쉽게 기계학습 훈련
확장시키는 방법
feat. Amazon EKS
7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
기계학습 엔지니어링 스킬
왜 중요할까요?
“데이터 과학자에서 AI 연구자로 들어서며…”
SKT T-Brain 전희원
http://freesearch.pe.kr/archives/4905
8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델
모델이란 무엇일까?
Model
9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델
기계학습 시대
데이터 과학자
experiment
10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델
experiment
모델 실험
- 학습 알고리즘
- 하이퍼 파라미터
기계학습 시대
11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델
experiment
머신
기계학습 시대
12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델
experiment
모델
기계학습 시대
13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델
조금 더 근본적인 생각
• 현실 세계의 모습을 투영하는 매개체
14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Rule based 모델
나의 주말 계획 모델
def my_weekend_plan(status):
if status == boring:
return play()
elif status == hungry:
return eat()
else:
return sleep()
15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Numerical 모델
거리 계산 모델
def distance_cal(velocity, time):
return velocity * time
복리 계산 모델
def interest_cal(amount, r, N):
return amount * (1+r)**N
16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Probabilistic 모델
동전 앞면이 나올 확률 모델
주가 예측 모델
Random walk 모델
Brownian motion 모델
p(H) = 0.5
p(T) = 0.5
17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
기계가 학습 한 모델
사람 손으로 풀기 어려운 복잡한 문제
?
y = Ax + Bx2
+ C
18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
기계가 학습 한 모델
기계한테 한번 맡겨 보자!
y = Ax + Bx2
+ C
19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
기계가 학습 한 모델
기계가 여러가지 경우를 계산
y = Ax + Bx2
+ C
20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
기계가 학습 한 모델
필연적으로 많은 기계가 필요
y = Ax + Bx2
+ C
21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
시작하게 된 고민
어떻게 하면 많은 기계들을 효율적으로 관리할 수 있을까?
22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
효율적 관리의 필요성
$ $
resource
usage
23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
효율적 관리의 필요성
ec2 instances
Busy Avail BusyBusy Busy
스케줄링
• 가용한 서버 찾아 삼만리
24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
효율적 관리의 필요성
ec2 instances
Exp02 Exp04 Exp01대기 목록 완료 목록
Exp03 Exp05Exp06 Exp07
학습 Job 관리
• 실행 위치
• 실행 완료 여부
• 장애 발생 여부
25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
효율적 관리의 필요성
ec2 instances
배포관리
• 라이브러리 관리
• 소스코드 관리
26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
효율적 관리의 필요성
ec2 instances
장애관리
• 문제가 되는 한 개 Job으로 인한 서버 장애
27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
기존 기계학습 방법
Scheduling
Resource
Management
ML Job
Management
직접 관리
28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
제안 방법
Scheduling
Resource
Management
ML Job
Management
위임 관리
29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Real world ML system
Configuration
Data Collection
Feature Extraction
Data
Verification
Model
Build
Analysis Tools
Process Management
Machine
Resource
Management
Serving
Infra
Monitoring
출처: Hidden Technical Debt in Machine Learning Systems” , Sculley et al.
30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Real world ML system
Configuration
Data Collection
Feature Extraction
Data
Verification
Model
Build
Analysis Tools
Process Management
Machine
Resource
Management
Serving
Infra
Monitoring
출처: "Hidden Technical Debt in Machine Learning Systems", Sculley et al.
31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Contents
효율적인 서버 관리의 필요성 & 제안방법
Kubernetes 소개
Kubernetes를 이용한 기계학습의 장점
Demo
마무리
32. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
Master
Master / Node
Nodes
34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
Master
Client tool: kubectl
Nodes
$ kubectl create -f exp01.yaml
Exp01
35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
Master
내부 Meta 데이터 저장소
Nodes
36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
Master
모든 것이 Object
Nodes
Deployment
Service
Job
Pod
37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
exp01이라는 Job을
apiVersion: batch/v1
kind: Job
metadata:
name: exp01
spec:
template:
spec:
containers:
- name: ml
image: $model_image
command: ["python", "train.py"]
args: [‘2’, ‘softmax’, ‘0.5’]
resources:
requests:
cpu: "2"
memory: "8Gi"
limits:
cpu: "4"
memory: "16Gi"
restartPolicy: OnFailure
Exp01
이렇게 실행하라
python train.py 2 softmax 0.5
이러한 자원을 가지고
38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
이름 정보
실행 정보
자원 정보
apiVersion: batch/v1
kind: Job
metadata:
name: exp01
spec:
template:
spec:
containers:
- name: ml
image: $model_image
command: ["python", "train.py"]
args: [‘2’, ‘softmax’, ‘0.5’]
resources:
requests:
cpu: "2"
memory: "8Gi"
limits:
cpu: "4"
memory: "16Gi"
restartPolicy: OnFailure
39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
모든 컨테이너는 pod로 실행
Exp01
$ kubectl get job
NAME DESIRED SUCCESSFUL AGE
exp01 1 0 5h
exp02 1 0 5h
40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
모든 컨테이너는 pod로 실행
Exp01
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
exp01-mnpbz 1/1 Running 0 5h
exp02-erpsuh 1/1 Running 0 5h
41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
Cluster Autoscaler
Need
more nodes!
NAME READY STATUS RESTARTS AGE
exp01-mnpbz 1/1 Pending 0 5h
exp02-erpsuh 1/1 Pending 0 5h
exp03-kzhrpj 1/1 Pending 0 5h
https://coffeewhale.com/kubernetes/eks/cluster-autoscaler/2019/04/14/eks-cas.html
42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
kubernetes 소개
쿠버네티스 설명 끝!
여러분은 이제
분산 기계학습 전문가b
43. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp01
스케줄링이 편리해집니다.
45. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp03
Exp01
Exp05
Exp07
Exp04
Exp02
Exp06
Exp08
스케줄링이 편리해집니다.
• 사람이 직접 실행하던 기계학습 훈련을
46. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp03
Exp01
Exp05
Exp07
Exp04
Exp02
Exp06
Exp08
스케줄링이 편리해집니다.
• 쿠버네티스에 맡길 수 있습니다.
47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
확장이 용이해집니다.
• 필요한 양의 리소스를 탄력적으로 사용합니다.
48. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp02
Exp01
Exp03
기계학습 Job 관리가 편리해집니다.
• 실행 / 완료 여부
• 장애 발생 여부
49. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
CPU
MEM
CPU
MEM
CPU
MEM
CPU
MEM
CPU
MEM
CPU
MEM
CPU
MEM
CPU
MEM
CPU
MEM
모니터링이 한눈에 보입니다.
• 리소스 사용량
• 기계학습 로그
50. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp02
Exp02
배포가 쉬워집니다.
• 라이브러리 관리
• 소스코드 관리
51. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp02
Exp02 Exp02
Exp02 Exp02
장애에 견고해 집니다.
• 문제가 되는 한 개의 Job만 장애 발생
52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
k8s를 이용한 기계학습의 장점
Exp02
장애에 견고해 집니다.
• 서버 자체에 문제가 생겨도 문제 X
쉽게 다른 Worker로 대체 가능
53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
No free lunch
직접 클러스터를 구축 해야 합니다.
마스터 노드가 죽지 않게 관리를 해야 합니다.
빨리 기계학습 모델을 돌려보고 싶은데 언제 다 설정하죠?
54. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
걱정 그만
저희에겐 Amazon EKS가 있습니다.
AWS kubernetes managed service
Master cluster
EKS
55. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
걱정 그만
eksctl과 함께라면 명령 한줄에 쿠버네티스 클러스터 뚝딱
https://github.com/weaveworks/eksctl
eksctl create cluster --name eks-ml --nodes-min=4 --nodes-max=8
56. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon EKS의 장점
Master Cluster 구성
• ClusterConfiguration 설정
• ELB 설정
• Certificate key 설정
• etcd DB 설정
57. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon EKS의 장점
Master 노드 관리
• HA 구성
• 사용량에 따른 Scale up / out
• etcd 관리
• 리소스 모니터링
58. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon EKS의 장점
비용 절감
Cluster size 직접 구축 (m5.large) Amazon EKS
3 nodes 시간당 0.354 USD 시간당 0.20 USD
5 nodes 시간당 0.590 USD 시간당 0.20 USD
7 nodes 시간당 0.826 USD 시간당 0.20 USD
59. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon EKS의 장점
IAM Authentication
60. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
61. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Demo
순서
1. 단일 job 실행
2. Multi 기계학습 Job 실행
3. Auto Scaling
4. Out of Memory 상황 발생
demo: https://github.com/hongkunyoo/eks-ml
62. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
사전 준비 사항
IAM User key 발급 & 권한 부여
• EKS
• CloudFormation
• EC2
• IAM
패키지 설치 (sudo ./setup.sh)
• kubectl
• eksctl
• aws-iam-authenticator
• metrics-server
• cluster-autoscaler
demo: https://github.com/hongkunyoo/eks-ml
63. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Demo
Create cluster
https://asciinema.org/a/vWWVkDEJY5MrYagosc6M6gVEc
64. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Demo
https://asciinema.org/a/fL8ygjaPupLionYHmmH9Sj9gz
Main demo
65. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
LG전자에서는
데이터 수집
Analysis & Intelligence
처리/저장
클라우드 기반 인프라 (AWS)
Dashboard /
Search Engine
개인정보 / 보안
LG Intellytics
내부 외부
일 30억건
내/외부
데이터 수집
대시보드
450 종
분석패널
6,000 여개
사용조직
940 팀
로그 센서
수리 고객
이메일 부품
품질
SNS
구매
후기
언론
보도
날씨
대기,
환경
지역
센서
생산
인구
통계
매출
콜상담
고객 인사이트 발굴
공정 지능화
프로세스 최적화
서비스 효율 향상
리스크 관리 / 신뢰성 증대
품질 예측 / 조기 감지
66. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
LG전자에서는
67. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
예측성능
고도화
모델링 엔진
• 31개 부품 및 35개 법인별 모델 세분화
• 12개 예측 모델 중 최적 모델 적용
• 주 단위 모델 업데이트
• 약 10,000개의 모델 학습
• 매주 약 8,160만회의 테스트
• 최종 약 940개의 최적 모델 선택
LG전자에서는
부품수요예측 모델
• 고객이 필요한 A/S 서비스 제공을 위한 부품 재고 관리
68. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
LG전자에서는
69. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
모델링 엔진
IAM role k8s user
lambda-role ml-user
70. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
마무리
2014년 Netflix 블로그: 분산 딥러닝 framework 소개
Distributed Neural Networks with GPUs in the AWS Cloud
71. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
2014년 Netflix 블로그: 분산 딥러닝 framework 소개
Distributed Neural Networks with GPUs in the AWS Cloud
마무리
https://medium.com/netflix-techblog/distributed-neural-networks-with-gpus-in-the-aws-cloud-ccf71e82056b
72. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
2014년 Netflix 블로그: 분산 딥러닝 framework 소개
Distributed Neural Networks with GPUs in the AWS Cloud
마무리
AWS EC2 + MIT StarCluster + Celery (distributed Job Queue)
73. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
마무리
이제는 Amazon EKS 하나로 해결
머리 아픈 일은 EKS에 맡기고 여러분은 핵심 모델링에 집중