File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 36
36
# if available. Let's check to see if `torch.cuda <https://pytorch.org/docs/stable/notes/cuda.html>`_
37
37
# or `torch.backends.mps <https://pytorch.org/docs/stable/notes/mps.html>` are available, otherwise we use the CPU.
38
38
39
- device = "cuda" if torch .cuda .is_available () else "mps" if torch .backends .mps .is_available () else "cpu"
39
+ device = (
40
+ "cuda"
41
+ if torch .cuda .is_available ()
42
+ else "mps"
43
+ if torch .backends .mps .is_available ()
44
+ else "cpu"
45
+ )
40
46
print (f"Using { device } device" )
41
47
42
48
##############################################
Original file line number Diff line number Diff line change 87
87
# operations in the neural network, we move it to the GPU or MPS if available.
88
88
89
89
# Get cpu, gpu or mps device for training.
90
- device = "cuda" if torch .cuda .is_available () else "mps" if torch .backends .mps .is_available () else "cpu"
90
+ device = (
91
+ "cuda"
92
+ if torch .cuda .is_available ()
93
+ else "mps"
94
+ if torch .backends .mps .is_available ()
95
+ else "cpu"
96
+ )
91
97
print (f"Using { device } device" )
92
98
93
99
# Define model
You can’t perform that action at this time.
0 commit comments