From 30978e3e5bce42d6e52d3d0853aa31ce7688bbcd Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sun, 19 Feb 2023 07:41:16 -0600 Subject: [PATCH] fix(api): only run GC is devices are passed --- api/onnx_web/chain/base.py | 4 ++-- api/onnx_web/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/onnx_web/chain/base.py b/api/onnx_web/chain/base.py index 702981a5..7e77bab7 100644 --- a/api/onnx_web/chain/base.py +++ b/api/onnx_web/chain/base.py @@ -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): """ diff --git a/api/onnx_web/utils.py b/api/onnx_web/utils.py index 1d6464b1..78befc16 100644 --- a/api/onnx_web/utils.py +++ b/api/onnx_web/utils.py @@ -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()):