Skip to content
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

Update model.py, to time the model loading time, to create a metric for system tuning to aim for, to optimize the model loading speed #222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from fastapi import HTTPException
from loguru import logger
from typing import Optional
import time

from common.logger import get_loading_progress_bar
from common.networking import handle_request_error
Expand Down Expand Up @@ -74,6 +75,7 @@ async def load_model_gen(model_path: pathlib.Path, **kwargs):
load_status = container.load_gen(load_progress, **kwargs)

progress = get_loading_progress_bar()
model_loading_started = time.time()
progress.start()

try:
Expand All @@ -95,6 +97,8 @@ async def load_model_gen(model_path: pathlib.Path, **kwargs):
progress.stop()
finally:
progress.stop()
model_loading_time = time.time() - model_loading_started
logger.info("Model loading took {:.2f} seconds.".format(model_loading_time))


async def load_model(model_path: pathlib.Path, **kwargs):
Expand Down