温馨提示×

Ubuntu中如何更新PyTorch版本

小樊
41
2025-09-15 01:43:46
栏目: 智能运维

在Ubuntu中更新PyTorch版本,常用方法有pip和conda两种,具体如下:

  • 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;CPU版本:pip install torch torchvision torchaudio
    3. 验证安装:import torchprint(torch.__version__)
  • conda安装
    1. 卸载旧版本:conda remove pytorch torchvision torchaudio
    2. 访问PyTorch官网,根据系统、CUDA版本等选择安装命令。如CUDA 11.7版本:conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch;CPU版本:conda install pytorch torchvision torchaudio cpuonly -c pytorch
    3. 验证安装:conda list torch查看版本信息。

0