Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pytorch check gpu

In [1]: import torch

In [2]: torch.cuda.current_device()
Out[2]: 0

In [3]: torch.cuda.device(0)
Out[3]: <torch.cuda.device at 0x7efce0b03be0>

In [4]: torch.cuda.device_count()
Out[4]: 1

In [5]: torch.cuda.get_device_name(0)
Out[5]: 'GeForce GTX 950M'

In [6]: torch.cuda.is_available()
Out[6]: True
Comment

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)
Comment

PREVIOUS NEXT
Code Example
Python :: python setter getter deleter 
Python :: invert dictionary python 
Python :: read google sheet from web to pandas python 
Python :: install python on windows subsystem for linux 
Python :: no module named torch 
Python :: iterate over df 
Python :: beuatiful soup find a href 
Python :: df sort values 
Python :: python make txt file 
Python :: how to check if an application is open in python 
Python :: python get filename from path 
Python :: how do i print the entire array pthon jupyter 
Python :: python selenium run javascript 
Python :: print today time python 
Python :: python datetime remove timezone 
Python :: how to check for a particular word in a text file using python 
Python :: find different values from two lists python 
Python :: epoch to datetime python 
Python :: how to set learning rate in keras 
Python :: python pyautogui how to change the screenshot location 
Python :: python join array of ints 
Python :: numpy mean 2 arrays 
Python :: anaconda-navigator command not found 
Python :: check if string url python 
Python :: discord py on ready 
Python :: pandas change dtype to string 
Python :: dice simulator in python 
Python :: ggplot2 histogram 
Python :: python combine side by side dataframes 
Python :: selenium exception handling python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =