Fonction torch.cuda.is_available de PyTorch


Pytorch torch 参考手册Manuel de référence Pytorch torch

torch.cuda.is_availableest une fonction dans PyTorch utilisée pour vérifier si CUDA est disponible.

Définition de fonction

torch.cuda.is_available()

Exemple d'utilisation

Exemple

import torch

# Vérifier si CUDA est disponible
if torch.cuda.is_available():
    print("CUDA disponible !")
    print("Nombre de GPU :", torch.cuda.device_count())
    print("Nom du GPU :", torch.cuda.get_device_name(0))
else:
    print("CUDA indisponible")

Pytorch torch 参考手册Manuel de référence Pytorch torch

Autres extensions