以下是在Ubuntu上安装PyTorch的步骤:
sudo apt update
。sudo apt install python3 python3-pip
。python3 -m venv pytorch_env
,source pytorch_env/bin/activate
。pip3 install torch torchvision torchaudio
。pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
。conda create -n pytorch_env python=3.9
。conda activate pytorch_env
。conda install pytorch torchvision torchaudio cpuonly -c pytorch
。conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch
。在Python中输入import torch
,print(torch.__version__)
,print(torch.cuda.is_available())
,查看版本号和CUDA是否可用。