Skip to content

Commit

Permalink
fix(api): unload old model before loading next one
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 22, 2023
1 parent abc1ae5 commit 9e26ee5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/onnx_web/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import gc
import numpy as np
import torch

from .image import (
expand_image,
Expand Down Expand Up @@ -54,6 +55,12 @@ def load_pipeline(pipeline: DiffusionPipeline, model: str, provider: str, schedu
print('reusing existing pipeline')
pipe = last_pipeline_instance
else:
print('unloading previous pipeline')
last_pipeline_instance = None
last_pipeline_scheduler = None
gc.collect()
torch.cuda.empty_cache()

print('loading different pipeline')
pipe = pipeline.from_pretrained(
model,
Expand Down

0 comments on commit 9e26ee5

Please sign in to comment.