Step 1: Create a Python 3.11 Environment
conda create --name pytorch_env python=3.11
This creates an environment with Python 3.11. Verify Python version after activation with:
python --version
This updated guide shows how to install PyTorch using conda with Python 3.11, the latest stable Python version supported by PyTorch.
conda create --name pytorch_env python=3.11
This creates an environment with Python 3.11. Verify Python version after activation with:
python --version
For modern conda installations (v4.10+):
conda activate pytorch_env
If using older versions:
source activate pytorch_env # Linux/macOS
activate pytorch_env # Windows
Current recommended commands (check pytorch.org for latest):
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
conda install pytorch torchvision torchaudio cpuonly -c pytorch
conda install pytorch torchvision torchaudio pytorch-rocm=5.6 -c pytorch -c rocm
Test both Python version and PyTorch functionality:
import torch, sys
print(f"Python version: {sys.version}")
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA/cuDNN version: {torch.version.cuda}")
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"Device count: {torch.cuda.device_count()}")
# Simple tensor operation test
x = torch.randn(3, 3)
print(f"\nTensor operation test:\n{x @ x.t()}")
conda install pytorch::pytorch torchvision torchaudio -c
pytorch
Category: PyTorch