在Ubuntu上更新PyTorch版本,主要有以下两种方法:
pip install --upgrade pip。pip uninstall torch torchvision torchaudio。pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117(需CUDA 11.7);若无需GPU,可直接用pip install torch torchvision torchaudio。conda update conda。conda activate your_environment_name。conda remove pytorch torchvision torchaudio。conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch(需CUDA 11.7);无需GPU则用conda install pytorch torchvision torchaudio cpuonly -c pytorch。安装完成后,可通过import torch; print(torch.__version__)验证版本。