Skip to content

Commit 06b121c

Browse files
authored
Merge pull request #83 from ahoust17/master
2 parents e884ba5 + 0802e4a commit 06b121c

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

atomai/trainers/trainer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class BaseTrainer:
6767
"""
6868
def __init__(self):
6969
set_train_rng(1)
70-
if torch.backends.mps.is_available():
71-
self.device = torch.device("mps") # backend for Apple silicon GPUs
70+
if hasattr(torch.backends, 'mps') and torch.backends.mps.is_available():
71+
self.device = torch.device('mps') # backend for Apple silicon GPUs
7272
elif torch.cuda.is_available():
7373
self.device = 'cuda'
7474
else:
@@ -367,8 +367,8 @@ def print_statistics(self, e: int, **kwargs) -> None:
367367
accuracy_metrics = "Accuracy"
368368
if torch.cuda.is_available():
369369
gpu_usage = gpu_usage_map(torch.cuda.current_device())
370-
elif torch.backends.mps.is_available():
371-
gpu_usage = gpu_usage_map(torch.mps.current_device())
370+
elif hasattr(torch.backends, 'mps') and torch.backends.mps.is_available():
371+
gpu_usage = ['N/A ', ' N/A']
372372
else:
373373
gpu_usage = ['N/A ', ' N/A']
374374
if self.compute_accuracy:

atomai/utils/nn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def load_weights(model: Type[torch.nn.Module],
4848
torch.manual_seed(0)
4949
if torch.cuda.device_count() > 0:
5050
checkpoint = torch.load(weights_path)
51-
elif torch.backends.mps.is_available():
51+
elif hasattr(torch.backends, 'mps') and torch.backends.mps.is_available():
5252
checkpoint = torch.load(weights_path, map_location='mps')
5353
else:
5454
checkpoint = torch.load(weights_path, map_location='cpu')

0 commit comments

Comments
 (0)