Skip to content

Commit

Permalink
feat: ✨ Add support for training on Apple M1/M2/M3 (mps) devices.
Browse files Browse the repository at this point in the history
Also add log printing of device used for training.
  • Loading branch information
rhoadesScholar committed Oct 24, 2024
1 parent 2d11926 commit bb9268b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dacapo/compute_context/local_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def device(self):
if free < self.oom_limit: # less than 1 GB free, decrease chance of OOM
return torch.device("cpu")
return torch.device("cuda")
elif torch.backends.mps.is_available():
return torch.device("mps")
else:
return torch.device("cpu")
return torch.device(self._device)
1 change: 1 addition & 0 deletions dacapo/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def train_run(run: Run, do_validate=True):
compute_context = create_compute_context()
run.model = run.model.to(compute_context.device)
run.move_optimizer(compute_context.device)
logger.info(f"Training on {compute_context.device}")

array_store = create_array_store()
run.trainer.iteration = trained_until
Expand Down

0 comments on commit bb9268b

Please sign in to comment.