以下是在Linux上配置PyTorch的步骤:
sudo apt update && sudo apt upgrade -y。sudo apt install python3 python3-pip。python3 -m venv pytorch_env创建,source pytorch_env/bin/activate激活。pip install torch torchvision torchaudio,CUDA版本如pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117。conda install pytorch torchvision torchaudio cudatoolkit=版本号 -c pytorch(有GPU时指定CUDA版本,无GPU用cpuonly)。import torch,print(torch.__version__)和print(torch.cuda.is_available()),查看版本和CUDA是否可用。