All Guides
PyTorch Setup
Install the Meta PyTorch deep learning library and learn basic usage.
Advanced30 min
Setup Steps
1. Install CPU version:
pip install torch torchvision torchaudio2. For NVIDIA GPU (CUDA 12.1):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu1213. Verify installation:
python3 -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"4. Simple model example:
python
import torch
import torch.nn as nn
class SimpleNet(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(784, 128)
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = torch.relu(self.fc1(x))
return self.fc2(x)
model = SimpleNet()
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(model.parameters(), lr=0.001)5. Move to GPU:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = model.to(device)6. Save model:
torch.save(model.state_dict(), 'model.pth')7. Load model:
model.load_state_dict(torch.load('model.pth'))Related Guides
Python Setup and pip
Install the Python programming language and pip package manager.
Jupyter Notebook Setup
Install Jupyter Notebook and use the interactive Python development environment.
TensorFlow Setup
Install the Google TensorFlow machine learning library and create your first model.
Conda/Miniconda Setup
Install the Miniconda package and environment manager. Isolate Python environments.