Skip to content

Commit

Permalink
Merge pull request #89 from yeelauren/patch-1
Browse files Browse the repository at this point in the history
Update torch_utils.py to use gpu if available
  • Loading branch information
StephenChan authored Jan 25, 2024
2 parents 4561f3f + 48dfcf2 commit fe6d775
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spacer/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def load_weights(model: Any,
:param weights_datastream: model weights, already loaded from storage
:return: well trained model
"""
# Use GPU if available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load weights
state_dicts = torch.load(weights_datastream,
map_location=torch.device('cpu'))
map_location=device)

with config.log_entry_and_exit('model initialization'):
new_state_dicts = OrderedDict()
Expand Down

0 comments on commit fe6d775

Please sign in to comment.