From 6d0ec4b00caf81f04466db7aa875d4a3f4ad1499 Mon Sep 17 00:00:00 2001 From: Ftps <63702646+Tps-F@users.noreply.github.com> Date: Sat, 29 Apr 2023 13:18:06 +0900 Subject: [PATCH] Escaping when device does not match (#203) --- config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 1082d2a..c95feff 100644 --- a/config.py +++ b/config.py @@ -50,7 +50,6 @@ class Config: def device_config(self) -> tuple: if torch.cuda.is_available(): - self.gpu_name = torch.cuda.get_device_name(int(self.device.split(":")[-1])) i_device = int(self.device.split(":")[-1]) self.gpu_name = torch.cuda.get_device_name(i_device) if ( @@ -76,6 +75,8 @@ class Config: with open("trainset_preprocess_pipeline_print.py", "r+") as f: strr = f.read().replace("3.7", "3.0") f.write(strr) + else: + self.gpu_name = None elif torch.backends.mps.is_available(): print("没有发现支持的N卡, 使用MPS进行推理") self.device = "mps"