Escaping when device does not match (#203)

This commit is contained in:
Ftps 2023-04-29 13:18:06 +09:00 committed by GitHub
parent b12e33891c
commit 6d0ec4b00c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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"