You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解决PyTorch与torchvision CUDA版本不匹配:卸载重装torchvision方法

解决PyTorch与torchvision CUDA版本不匹配问题

RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA versions. PyTorch has CUDA Version=11.7 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.

卸载torchvision

执行以下命令彻底卸载当前torchvision:

pip uninstall torchvision -y

安装匹配CUDA 11.7的torchvision

根据已安装的PyTorch版本,选择对应版本的torchvision(确保CUDA版本为11.7):

  • 若PyTorch版本为1.13.x+cu117,安装torchvision 0.14.x+cu117:
    pip install torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
    
  • 若PyTorch版本为2.0.x+cu117,安装torchvision 0.15.x+cu117:
    pip install torchvision==0.15.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
    
  • 若PyTorch版本为2.1.x+cu117,安装torchvision 0.16.x+cu117:
    pip install torchvision==0.16.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
    

确认版本匹配

安装完成后,可运行以下命令验证版本:

pip show torch torchvision

检查输出中的版本信息,确保两者的CUDA版本均为11.7。

内容的提问来源于stack exchange,提问作者cebri-ctrl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 21:05:01