From d872a3bc4b0c2c006d17ab9caa46f57b4e2f879e Mon Sep 17 00:00:00 2001 From: Eric Hofesmann Date: Fri, 13 Dec 2024 12:46:23 -0500 Subject: [PATCH 1/2] similarity race condition patch --- fiftyone/utils/torch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fiftyone/utils/torch.py b/fiftyone/utils/torch.py index c8390dfc5b..112a9d5fac 100644 --- a/fiftyone/utils/torch.py +++ b/fiftyone/utils/torch.py @@ -572,9 +572,9 @@ def __exit__(self, *args): if self.config.cudnn_benchmark is not None: torch.backends.cudnn.benchmark = self._benchmark_orig self._benchmark_orig = None - - self._no_grad.__exit__(*args) - self._no_grad = None + if self._no_grad is not None: + self._no_grad.__exit__(*args) + self._no_grad = None @property def media_type(self): From 4fdcc9caf00853a04cf11e6ff809d2b9007a20ab Mon Sep 17 00:00:00 2001 From: brimoor Date: Tue, 17 Dec 2024 19:32:39 -0500 Subject: [PATCH 2/2] lint --- fiftyone/utils/torch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fiftyone/utils/torch.py b/fiftyone/utils/torch.py index 112a9d5fac..88ae1f6f20 100644 --- a/fiftyone/utils/torch.py +++ b/fiftyone/utils/torch.py @@ -572,6 +572,7 @@ def __exit__(self, *args): if self.config.cudnn_benchmark is not None: torch.backends.cudnn.benchmark = self._benchmark_orig self._benchmark_orig = None + if self._no_grad is not None: self._no_grad.__exit__(*args) self._no_grad = None