-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from ahoust17/master
Compatibility with Apple Silicon GPUs
- Loading branch information
Showing
3 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = '0.7.8' | ||
version = '0.7.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,12 @@ class BaseTrainer: | |
""" | ||
def __init__(self): | ||
set_train_rng(1) | ||
self.device = 'cuda' if torch.cuda.is_available() else 'cpu' | ||
if torch.backends.mps.is_available(): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ziatdinovmax
Author
Collaborator
|
||
self.device = torch.device("mps") # backend for Apple silicon GPUs | ||
elif torch.cuda.is_available(): | ||
self.device = 'cuda' | ||
else: | ||
self.device = 'cpu' | ||
self.net = None | ||
self.criterion = None | ||
self.optimizer = None | ||
|
@@ -362,6 +367,8 @@ def print_statistics(self, e: int, **kwargs) -> None: | |
accuracy_metrics = "Accuracy" | ||
if torch.cuda.is_available(): | ||
gpu_usage = gpu_usage_map(torch.cuda.current_device()) | ||
elif torch.backends.mps.is_available(): | ||
gpu_usage = gpu_usage_map(torch.mps.current_device()) | ||
else: | ||
gpu_usage = ['N/A ', ' N/A'] | ||
if self.compute_accuracy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Except this breaks things for others if they do not have a version of pytorch that supports this. :(
E.g., I'm now getting this error:
module 'torch.backends' has no attribute 'mps'