以下是一些PyTorch Linux版安装教程:
sudo apt install python3 python3-pip
(Ubuntu/Debian)或sudo yum install python3 python3-pip
(CentOS/RHEL)安装。然后创建虚拟环境(可选)python3 -m venv pytorch-env
,激活source pytorch-env/bin/activate
,最后安装pip install torch torchvision torchaudio
。pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu<cuda_version>
,将<cuda_version>
替换为实际CUDA版本号。conda install pytorch torchvision torchaudio cpuonly -c pytorch
,GPU版本为conda install pytorch torchvision torchaudio cudatoolkit=<cuda_version> -c pytorch -c nvidia
,同样需先安装对应CUDA工具包。