温馨提示×

Ubuntu系统如何升级PyTorch

小樊
53
2025-08-11 22:11:37
栏目: 智能运维

在Ubuntu系统上升级PyTorch,主要有以下两种推荐方法:

  • 使用pip安装
    1. 打开终端(Ctrl + Alt + T)。
    2. 卸载旧版本:pip uninstall torch torchvision torchaudio
    3. 访问PyTorch官网,根据CUDA版本选择安装命令,如CUDA 11.7:pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117;若用CPU版本则:pip install torch torchvision torchaudio
    4. 验证更新:pip show torch查看版本。
  • 使用conda安装
    1. 打开终端。
    2. 激活虚拟环境(若有):conda activate <your_env>
    3. 卸载旧版本:conda remove pytorch torchvision torchaudio
    4. 安装新版本:conda install pytorch torchvision torchaudio cudatoolkit=<your_cuda_version> -c pytorch,如conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch,不使用GPU可省略cudatoolkit参数。
    5. 验证更新:conda list torch查看版本。

0