Linux中PyTorch的安装教程
·
在安装PyTorch之前,我们需要确保已经安装了Python和pip。可以使用以下命令检查是否已经安装:
python --version
pip --version
如果没有安装,可以使用以下命令安装:
sudo apt-get update
sudo apt-get install python3
sudo apt-get install python3-pip
在Linux系统下,我们可以使用pip来安装PyTorch(默认GPU)。可以使用以下命令安装:
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple
``
如果需要安装特定版本的PyTorch,可以使用以下命令:
pip3 install torch1.8.1+cpu torchvision0.9.1+cpu torchaudio==0.8.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html
安装完成后,我们可以使用以下命令测试PyTorch是否安装成功:
python3 -c “import torch; print(torch.version)”
如果输出了PyTorch的版本号,则说明安装成功

更多推荐



所有评论(0)