Skip to content

Commit

Permalink
Backend pytorch: Update the code to use GPU by default (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
supercgor authored Oct 30, 2023
1 parent 4b8ee44 commit f0d3abe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deepxde/backend/pytorch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
# An alternative way is to use GPU by default if GPU is available, which is similar to
# TensorFlow.
if torch.cuda.is_available():
torch.set_default_tensor_type(torch.cuda.FloatTensor)
if Version(torch.__version__) >= Version("2.1.0"):
torch.set_default_device("cuda")
else:
torch.set_default_tensor_type(torch.cuda.FloatTensor)


lib = torch
Expand Down

0 comments on commit f0d3abe

Please sign in to comment.