在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命令。