PyTorch Installation Guide: Quick Steps
安装PyTorch可以通过以下步骤完成:
- 确认你的Python版本:PyTorch支持Python 3.6或更高版本。你可以通过在终端中运行以下命令来查看你的Python版本:
python --version
- Install the latest version of pip by upgrading it using the following command:
pip install --upgrade pip
- 安装PyTorch:你可以在PyTorch官方网站上找到适合你系统的安装命令。例如,如果你使用的是CUDA 10.2,Python 3.8和Linux操作系统,可以使用以下命令安装PyTorch:
pip install torch==1.7.0+cu102 torchvision==0.8.1+cu102 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
- Verification of installation: You can input the following code in the Python terminal to confirm if PyTorch has been successfully installed:
import torch
print(torch.__version__)
If no errors have occurred and PyTorch version is successfully printed, then PyTorch has been successfully installed on your system.