以下是在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 torchaudiopip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118conda install pytorch torchvision torchaudio cpuonly -c pytorchconda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch -c nvidiapython3 -c "import torch; print(torch.__version__); print(torch.cuda.is_available())" 若安装成功,会显示PyTorch版本号,GPU版本会显示True。