Guest User

Untitled

a guest
Oct 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. # 选择设备,选择使用GPU(cuda)训练
  2.  
  3. # first way
  4. if torch.cuda.is_available():
  5. device = torch.device("cuda:0")
  6. else:
  7. device = torch.device("cpu")
  8.  
  9.  
  10. # second way
  11. device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
Add Comment
Please, Sign In to add comment