From 827939783df9c5d3a3766a9ea53234807670dc93 Mon Sep 17 00:00:00 2001 From: Alain KOMATY <alain.komaty@idiap.ch> Date: Tue, 7 Jun 2022 18:45:32 +0200 Subject: [PATCH] fixed the device selection issue --- bob/pad/face/deep_pix_bis.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bob/pad/face/deep_pix_bis.py b/bob/pad/face/deep_pix_bis.py index c6e976c8..38ef6029 100644 --- a/bob/pad/face/deep_pix_bis.py +++ b/bob/pad/face/deep_pix_bis.py @@ -178,9 +178,7 @@ class DeepPixBisClassifier(BaseEstimator, ClassifierMixin): self.scoring_method ) ) - self.device = torch.device( - device or "cuda" if torch.cuda.is_available() else "cpu" - ) + self.device = device self.threshold = threshold logger.debug( @@ -275,5 +273,9 @@ class DeepPixBisClassifier(BaseEstimator, ClassifierMixin): return {"requires_fit": False} def place_model_on_device(self): + if self.device is None: + self.device = torch.device( + "cuda" if torch.cuda.is_available() else "cpu" + ) if self.model is not None: self.model.to(self.device) -- GitLab