以下是在Ubuntu上配置PyTorch环境的步骤:
sudo apt update,sudo apt upgrade。sudo apt install python3 python3-pip。python3 -m venv pytorch-env,source pytorch-env/bin/activate。wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-ubuntu2004-11-7-local_11.7.1-450.51.06-1_amd64.deb,然后按步骤安装。pip install torch torchvision torchaudio,CUDA 11.7版本pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117。conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch -c conda-forge。import torch,print(torch.__version__),print(torch.cuda.is_available())。