温馨提示×

CentOS上PyTorch的版本如何更新

小樊
45
2025-09-04 02:13:44
栏目: 智能运维

在CentOS上更新PyTorch版本,主要有以下两种方法:

  • 使用pip安装
    1. 卸载旧版本:pip uninstall torch torchvision torchaudio
    2. 访问PyTorch官网,根据系统及CUDA版本选择安装命令。如使用CUDA 11.7,命令为pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117;若无需GPU支持,可直接用pip install torch torchvision torchaudio
    3. 验证更新:import torchprint(torch.__version__)
  • 使用conda安装
    1. 若用Anaconda或Miniconda,先更新conda:conda update conda
    2. 卸载旧版本:conda remove pytorch torchvision torchaudio cudatoolkit
    3. 安装新版本,如CUDA 11.7版本:conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch;不需要GPU则用conda install pytorch torchvision torchaudio cpuonly -c pytorch
    4. 验证更新:conda list torch

0