Skip to content

Commit

Permalink
fix(api): only run GC is devices are passed
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Feb 19, 2023
1 parent 3789862 commit 30978e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/onnx_web/chain/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ class ChainPipeline:

def __init__(
self,
stages: List[PipelineStage] = [],
stages: List[PipelineStage] = None,
):
"""
Create a new pipeline that will run the given stages.
"""
self.stages = list(stages)
self.stages = list(stages or [])

def append(self, stage: PipelineStage):
"""
Expand Down
4 changes: 2 additions & 2 deletions api/onnx_web/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def get_size(val: Union[int, str, None]) -> SizeChart:
raise Exception("invalid size")


def run_gc(devices: List[DeviceParams] = []):
def run_gc(devices: List[DeviceParams] = None):
logger.debug(
"running garbage collection with %s active threads", threading.active_count()
)
gc.collect()

if torch.cuda.is_available():
if torch.cuda.is_available() and devices is not None:
for device in devices:
logger.debug("running Torch garbage collection for device: %s", device)
with torch.cuda.device(device.torch_str()):
Expand Down

0 comments on commit 30978e3

Please sign in to comment.