How to Check if PyTorch is Installed with GPU Support A Comprehensive Guide

To check if PyTorch is installed with GPU support, you can run the following code in a Python interpreter:

import torch

if torch.cuda.is_available():
    print("PyTorch is installed with GPU support!")
else:
    print("PyTorch is installed without GPU support.")

This code first imports the torch module and then checks if a GPU is available by calling torch.cuda_is_available(). If a GPU is available, the code will print the message “PyTorch is installed with GPU support!” If no GPU is available, the code will print the message “PyTorch is installed without GPU support.”

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *