From 810a30fcfa21893f3d65b34195a2c8f05bb5a6a6 Mon Sep 17 00:00:00 2001 From: adldotori Date: Mon, 3 Apr 2023 12:42:08 +0000 Subject: [PATCH] fix: conditional import torch --- utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils.py b/utils.py index e9c44df..ff932a0 100644 --- a/utils.py +++ b/utils.py @@ -3,7 +3,6 @@ import random import uuid import numpy as np -import torch os.makedirs("image", exist_ok=True) os.makedirs("audio", exist_ok=True) @@ -15,8 +14,13 @@ os.makedirs("playground", exist_ok=True) def seed_everything(seed): random.seed(seed) np.random.seed(seed) - torch.manual_seed(seed) - torch.cuda.manual_seed_all(seed) + try: + import torch + + torch.manual_seed(seed) + torch.cuda.manual_seed_all(seed) + except: + pass return seed