Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pytorch check GPU

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
#或device = torch.device("cuda:0")
device1 = torch.device("cuda:1")  
for batch_idx, (img, label) in enumerate(train_loader):
    img=img.to(device)
    label=label.to(device)
Source by www.feiguyunai.com #
 
PREVIOUS NEXT
Tagged: #pytorch #check #GPU
ADD COMMENT
Topic
Name
9+8 =