“gpu de vérification pytorch” Réponses codées

pytorch vérifie si l'utilisation du GPU

import torch

torch.cuda.is_available()
>>> True

torch.cuda.current_device()
>>> 0

torch.cuda.device(0)
>>> <torch.cuda.device at 0x7efce0b03be0>

torch.cuda.device_count()
>>> 1

torch.cuda.get_device_name(0)
>>> 'GeForce GTX 950M'
bougui

gpu de vérification pytorch

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
Worrisome Weasel

Vérifiez la version Cuda Pytorch

torch.version.cuda
Pouyan

pytorch obtient le numéro de GPU

torch.cuda.device_count()
Smoggy Squirrel

gpu de vérification pytorch

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)
Wide-eyed Wolverine

Réponses similaires à “gpu de vérification pytorch”

Questions similaires à “gpu de vérification pytorch”

Plus de réponses similaires à “gpu de vérification pytorch” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code