以下是 PyTorch 的安装步骤,适用于不同操作系统和 Python 版本。
系统要求
- Python 3.6 或更高版本
- 确保您的系统满足以下要求:
- Windows: Windows 7 或更高版本
- macOS: macOS 10.13 或更高版本
- Linux: Ubuntu 16.04 或更高版本
安装步骤
- 打开命令行工具。
- 安装 PyTorch,使用以下命令:
pip install torch torchvision torchaudio
- (可选)安装 CUDA 支持(如果您使用的是 NVIDIA GPU):
pip install torch torchvision torchaudio torchvision-nightly -f https://download.pytorch.org/whl/torch_stable.html