From 9aa886293fa24360927701b04adfe014a39e5801 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Tue, 22 Sep 2020 19:08:23 +0000 Subject: [PATCH] fix: only import cupy if cuda available Signed-off-by: Dev Singh --- analysis-master/tra_analysis/regression.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/analysis-master/tra_analysis/regression.py b/analysis-master/tra_analysis/regression.py index 25f10c30..c57d3aa6 100644 --- a/analysis-master/tra_analysis/regression.py +++ b/analysis-master/tra_analysis/regression.py @@ -48,13 +48,16 @@ __all__ = [ ] import torch -import cupy as cp import numpy as np + global device device = "cuda:0" if torch.torch.cuda.is_available() else "cpu" +if device !== "cpu": + import cupy as cp + #todo: document completely def set_device(self, new_device):