Ubuntu与PyTorch的集成方式主要有以下两种,均需先安装Python环境:
pip3 install torch torchvision torchaudiopip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117(以CUDA 11.7为例)conda install pytorch torchvision torchaudio cpuonly -c pytorchconda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch安装后可通过import torch和print(torch.cuda.is_available())验证,若返回True则表示GPU加速可用。