Skip to content

Commit 76011da

Browse files
committed
update
1 parent 5887be6 commit 76011da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

recipes_source/recipes/changing_default_device.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@
3535
print(mod(torch.randn(128, 20)).device)
3636

3737
#########################################
38-
# You can also set it globally like this:
38+
# You can also set it globally like this:
3939

4040
torch.set_default_device('cuda')
4141

4242
mod = torch.nn.Linear(20, 30)
4343
print(mod.weight.device)
4444
print(mod(torch.randn(128, 20)).device)
4545

46+
torch.set_default_device('cpu')
47+
4648
################################################################
4749
# This function imposes a slight performance cost on every Python
4850
# call to the torch API (not just factory functions). If this

0 commit comments

Comments
 (0)