Install PyTorch
-
Ensure Python 3.10+ and pip are installed.
-
For CPU (Linux/macOS/Windows):
pip3 install torch torchvision torchaudio
For CUDA 12.6 (Linux):
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
- Verify installation in Python:
import torch
x = torch.rand(5, 3)
print(x)
print(torch.cuda.is_available())
Use Google Colab for quick start without local install: Open Colab and run !pip3 install torch torchvision torchaudio.