cheat-tos / serving Goto Github PK
View Code? Open in Web Editor NEWDKT Project Served by Airflow / BentoML / Docker Swarm
DKT Project Served by Airflow / BentoML / Docker Swarm
(수행 전) 병렬처리가 필요한 DL 모델과 비교적 그렇지 않은 ML 모델 Serving 방식 차이 알아보기
(수행 후) 실서버 목적으로 한다면 GPU 서버보다는 최대한 경량화하여 CPU 서버를 사용하는 서빙이 맞다고 합니다.
프로젝트에 덧붙이고 싶은 기능들을 제안합니다. 아래의 종류에 맞게 체크해주세요.
Data
Preprocessing
Model
Feature
Paper
Serving
ETC (ex - library, reference)
==========
Baseline BERT 모델 MLProject로 포팅하여 MLFlow에 로컬로 올려보기.
잘되면, cloud infra에 올려봅시다.
==========
airflow를 이용하여 dataload, train, reload(serve) 까지 진행이 되는것을 확인할 수 있었다.
client side page의 모습
ngrok를 이용하여 간단하게 외부에서도 접근할 수 있는 것을 확인할 수 있었다.
깃헙에 소스공유해주셔서 감사합니다.
데이터 엔지니어링 공부하다가 실례를 무릅쓰고 이렇게 질문드립니다.
https://github.com/cheat-tos/serving/blob/main/service.py
해당 소스에서
bentoml endpoint를 하나로 설정해두신 이유가 있을까요??
(수행 전) 학습 후 model 파일 object storage로 저장하도록 train.py를 수정하려고 합니다.
(수행 후) 결과는 어땠는지
(수행 전) inference용 bentoml server는 도커라이징 되었고, train.py가 있는 이미지와 flask_server를 도커라이징 해보려합니다.
(수행 후) inference 서버, flask 서버 image화 완료했습니다.
플라스크 서버 컨테이너
─── inference 컨테이너
└── (re)train 용 컨테이너
총 세개를 둘 생각입니다. 플라스크는 상시 떠있고, airflow에서 cron으로 train을 수행해 inference 컨테이너를 죽이고 기존의 포트를 train이 물도록 하면 컨테이너 교체가 가능합니다.
Docker compose로 inference 컨테이너와 flask 컨테이너가 컨테이너간 통신 가능하도록 네트워크로 묶었습니다.
(수행 전) 지금은 default argument로 container의 inference가 수행되고 있는데, 컨테이너 학습시 인자로 config setting을 조작할 수 있도록 만듭니다.
(수행 후) container로 학습하지 않고 P40 서버 상에서 학습하기로 했으며, 이때 train에 config 인자를 주어 모델을 바꿔서 학습할 수 있게 했습니다.
https://stackoverflow.com/questions/53543881/docker-run-pass-arguments-to-entrypoint
(수행 전) MLOps Conference, Full Stack Deep Learning 등에서 관련 내용 찾아보기
(수행 후) 모델 학습관리는 MLFlow 사용, 배포는 SageMaker 사용하거나 Ec2 배포로 들어갈듯
Airflow
Luigi
MLFlow
KubeFlow
Argo
난이도, 레퍼런스 등을 고려해봤을때 해볼만한 것은
MLFlow > AirFlow > KubeFlow > 외 나머지
MLFlow 사용 후 AzureML 또는 SageMaker이용하여 배포 가능하다고!
(수행 전) Production service에 올리기는 MLflow보다 BentoML이 낫다던데, 일단 MLflow로 먼저 올려보고 차이점 알아보기.
(수행 후) BentoML은 실제 많은 기능을 제공하였으며, 이번 프로젝트 서빙에서 주축이 되는 프레임워크로 사용
학습되어 있는 모델 파일, model.pt
inference 시 예측할 test data, pandas dataframe type으로 pickle로 저장
모델 학습, 데이터 전처리 등에서 사용되는 config 파일, json 파일
test dataset의 categorical feature를 training dataset과 같이 label encoding해줄 np.array type, pickle로 저장
(assessmentItemID_classes, testId_classes, KnowledgeTag_classes)
해당 url에 접속하였을 때, 실행되는 함수에서 input 또는 batch process를 설정해주는 데코레이터
해당 데코레이터 다음에 나오는 함수 명이 url 명이 된다.
ex) 함수명 : predict, url : 0.0.0.0:port/predict
@bento.artifact()
에서 설정한 artifacts들을 [bento class].pack()
으로 packing 해주고 save()
를 해주면 최신 버전의 디렉토리가 생성된다.CLI에서 bentoml serve [bento class]:latest
를 입력하여 serving
—-port
를 통해 port 번호 설정 가능
아래 코드를 통해 파이썬에서 테스트 가능
res = requests.post('http://0.0.0.0:5000/predict', json= data)
print(res.text)
requests.post
로 데이터를 bentoml로 post한 뒤 결과를 받아 다시 랜더링하는 방식(수행 전) flask로 들어온 요청을 여러 포트로 로드밸런싱하는 Nginx를 추가합니다.
(수행 후) Nginx나 Traefik 대신 Docker Swarm을 사용합니다.
(수행 전) 기존 baseline lstm으로 training, inference되던 bentoml 코드를 유지님의 saint 코드로 변경
(수행 후) train, inference 코드에 saint 추가, s3 추가
(수행 전) 하나의 flask 서버로 들어온 요청에 대하여 Load Balancing과 fail over check, Rolling update까지 수행할 수 있는 오케스트레이션 툴을 사용합니다.
(수행 후)
프로젝트에 덧붙이고 싶은 기능들을 제안합니다. 아래의 종류에 맞게 체크해주세요.
Data
Preprocessing
Model
Feature
Paper
Serving
ETC (ex - library, reference.
==========
이전에 언급했던 KF Serving 레퍼런스를 토대로 모델 서빙을 합니다.
클라우드는 아직 사용하지 않습니다.
성진/유지님이 만드신 SAINT 모델을 사용합니다.
==========
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.