在Ubuntu上更新PyTorch版本,可以按照以下步骤进行:
卸载旧版本:
pip uninstall torch torchvision torchaudio
安装新版本:
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
如果你使用的是Anaconda或Miniconda,可以通过conda来管理PyTorch版本。
卸载旧版本:
conda remove pytorch torchvision torchaudio cudatoolkit
安装新版本:
conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch
安装完成后,可以通过以下命令验证PyTorch是否安装成功以及版本是否正确:
import torch
print(torch.__version__)
sudo
命令或者以管理员身份运行终端。通过以上步骤,你应该能够在Ubuntu上成功更新PyTorch版本。