以下是在CentOS系统下安装PyTorch的几种常见教程:
sudo yum update -y
。conda create -n pytorch_env python=3.8
,conda activate pytorch_env
。conda install pytorch torchvision torchaudio cpuonly -c pytorch
;GPU版本需先安装CUDA和cuDNN,再用conda install pytorch torchvision torchaudio cudatoolkit=版本号 -c pytorch
。import torch
,print(torch.__version__)
,print(torch.cuda.is_available())
。sudo yum update -y
,sudo yum install -y python3 python3-pip
等。pip3 install torch torchvision torchaudio
;GPU版本用pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/对应CUDA版本
。