在Ubuntu上安装PyTorch,可通过以下两种常见方式下载安装包:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118来下载安装。若无GPU,可使用pip3 install torch torchvision torchaudio命令安装CPU版本。conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch -c nvidia,无GPU则使用conda install pytorch torchvision torchaudio cpuonly -c pytorch命令。