-
Notifications
You must be signed in to change notification settings - Fork 2
추론요청 시나리오 작성 모듈과 라운드로빈으로 요청을 엣지장비들에 전송하는 스케줄러 구현 #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kh3654po
wants to merge
13
commits into
ddps-lab:main
Choose a base branch
from
kh3654po:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
75db787
포아송 분포를 따르도록 추론 요청 시나리오를 작성하는 모듈
kh3654po 8aba62f
추론요청들을 라운드로빈 방식으로 엣지장비에게 전송하는 스케줄러 구현
kh3654po 818b82f
추론요청 워크로드 생성 코드 수정
kh3654po 11b3a8c
각 모델별 추론요청시 보낼 데이터를 미리 전처리 후 저장하는 모듈
kh3654po e2cd4c4
추론요청시 전처리된 데이터를 전송하는것으로 변경했으므로 전처리 코드 삭제
kh3654po 9147915
전처리 모듈에서 불필요하게 import된 모듈 삭제
kh3654po aba5982
요청을 처리 후 각 장비의 idle 시간과 추론시간을 출력하도록 변경
kh3654po 732646f
전처리 함수에서 소스데이터의 절대경로를 받도록 수정
kh3654po 0108318
모든 요청을 처리 후 결과를 출력하도록 수정
kh3654po 2a56743
시나리오를 생성할 때 매초 요청량이 일정하도록 생성하는 기능추가
kh3654po 2b31071
round robin으로 스케줄링하는 코드 리팩토링
kh3654po dd07358
gpu를 사용해 행렬연산하는 c, cuda 코드 구현
kh3654po 054d4ee
gpu를 사용해 행렬연산하는 go, cuda 코드 구현
kh3654po File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| from numpy import random | ||
| import pickle as pk | ||
|
|
||
| # (modle name, requests per second) | ||
| inference_request_info = [ | ||
| ('mobilenet_v1', 20), | ||
| ('mobilenet_v2', 2), | ||
| ('inception_v3', 2), | ||
| ('yolo_v5', 1) | ||
| ] | ||
|
|
||
| file_name = 'workload4' | ||
| req_time_num = 20 | ||
|
|
||
| def create_inference_request_workload_by_poisson(req_time): | ||
| requests = [[] for _ in range(req_time)] | ||
| total_req_num = 0 | ||
| for (model_name, req_per_sec) in inference_request_info: | ||
| workloads = random.poisson(lam=req_per_sec, size=req_time) | ||
| for idx in range(req_time): | ||
| requests[idx].extend([model_name for _ in range(workloads[idx])]) | ||
| total_req_num += sum(workloads) | ||
|
|
||
| for idx in range(req_time): | ||
| random.shuffle(requests[idx]) | ||
|
|
||
| workload_info = {} | ||
| workload_info['total_request_num'] = total_req_num | ||
| workload_info['requests'] = requests | ||
|
|
||
| return workload_info | ||
|
|
||
|
|
||
| def create_inference_request_workload_regularly(req_time): | ||
| requests = [[] for _ in range(req_time)] | ||
| total_req_num = 0 | ||
| for (model_name, req_per_sec) in inference_request_info: | ||
| for idx in range(req_time): | ||
| requests[idx].extend([model_name for _ in range(req_per_sec)]) | ||
| total_req_num += req_per_sec | ||
|
|
||
| for idx in range(req_time): | ||
| random.shuffle(requests[idx]) | ||
|
|
||
| workload_info = {} | ||
| workload_info['total_request_num'] = total_req_num | ||
| workload_info['requests'] = requests | ||
|
|
||
| return workload_info | ||
|
|
||
| def save_workload_info_to_file(file_name, workloads): | ||
| with open(file_name, 'wb') as f: | ||
| pk.dump(workloads, f) | ||
|
|
||
|
|
||
| def load_workload_info_from_file(file_name): | ||
| with open(file_name, 'rb') as f: | ||
| loaded_workloads = pk.load(f) | ||
| return loaded_workloads | ||
|
|
||
|
|
||
| # workloads = create_inference_request_workload_by_poisson(req_time_num) | ||
| # workloads = create_inference_request_workload_regularly(req_time_num) | ||
| # save_workload_info_to_file(file_name, workloads) | ||
| # loaded_workload_info = load_workload_info_from_file(file_name) | ||
| # print(loaded_workload_info) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import tensorflow as tf | ||
| import json | ||
| import importlib | ||
| import os.path | ||
|
|
||
|
|
||
| data_source_info = {'mobilenet_v1': '../dataset/imagenet/imagenet_1000_raw/n01843383_1.JPEG', | ||
| 'mobilenet_v2': '../dataset/imagenet/imagenet_1000_raw/n01843383_1.JPEG', | ||
| 'inception_v3': '../dataset/imagenet/imagenet_1000_raw/n01843383_1.JPEG', | ||
| 'yolo_v5': '../dataset/coco_2017/coco/images/val2017/000000089761.jpg', | ||
| } | ||
|
|
||
| def get_file_path(filename): | ||
| return os.path.join(os.path.dirname(__file__), filename) | ||
|
|
||
| def regist_preprocessed_datas(request_type): | ||
| preprocessed_datas = {} | ||
|
|
||
| for model in data_source_info.keys(): | ||
| if request_type == 'rest': | ||
| preprocessing_module = importlib.import_module(f"{model}.preprocessing") | ||
| data_source = data_source_info.get(model) | ||
|
|
||
| data = json.dumps({"instances": preprocessing_module.run_preprocessing(get_file_path(data_source)).tolist()}) | ||
| preprocessed_datas.update({model: data}) | ||
| elif request_type == 'grpc': | ||
| preprocessing_module = importlib.import_module(f"{model}.preprocessing") | ||
| data_source = data_source_info.get(model) | ||
| data = tf.make_tensor_proto(preprocessing_module.run_preprocessing(get_file_path(data_source))) | ||
| preprocessed_datas.update({model: data}) | ||
|
|
||
| return preprocessed_datas |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for 문에서 req_time 만큼 실행하고 poission 의 size 가 req_time 인게 잘 이해가 안되네. 결과물이 어떤 형태일지 예를 들어주면 좋을것 같아.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req_time은 몇초동안 요청을 받을지를 나타냅니다. 예를 들어 3이라면 3초동안의 요청 정보를 만들어줍니다.
결과는 리스트로 예시는 아래와 같습니다. 각각의 리스트는 1초동안 들어오는 요청량입니다.