报错
058
PyTorch、CUDA 运行库与加速库冲突
含未核实说明
启动直接崩:torch / torchvision / torchaudio 三者 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.
检索关键词
Detected that PyTorch and torchvision were compiled with different CUDA versions、Detected that PyTorch and TorchAudio were compiled with different CUDA versions、torchvision has CUDA Version、reinstall the torchvision that matches your PyTorch install、ComfyUI fails to start with a RuntimeError
先看这一句
ComfyUI 在 import 阶段就抛 RuntimeError 无法启动,报错文字直接说明两个包的 CUDA 版本号不一致;也可能表现为 torch 与 torchvision+cuXXX 后缀不同(如 torch 2.7.0+cu128 配 torchvision 0.19.1+cu124)。
适用版本 全版本通用。50 系显卡场景下必须三者都来自 cu128(或更高)索引;只把 torch 换成 cu128 而留着旧的 torchvision 就会命中本条。
·
核实日期 2026-09-26
·
状态 可能已过期,正在复核
适用环境:Windows 便携版、秋叶/绘世整合包、ComfyUI Desktop、Linux + 云 GPU、Docker/服务器
现象与触发场景
常见触发场景:
- 只单独升级了 torch(pip install --upgrade torch),torchvision/torchaudio 还是旧版
- 从 nightly 索引装 torch 而没有同时装匹配的 torchvision/torchaudio
- 某个节点的 requirements.txt 单独升了 torchvision,或 xformers/bitsandbytes 之类把 torch 换掉
根因
- torch、torchvision、torchaudio 是同一个发布批次的一套产物,各自的 wheel 里都编译进了具体的 CUDA 版本号;版本号不一致时运行时校验会直接失败。
- PyTorch 论坛的 sm120 帖子里就有用户实测到这个错误:请求 torch==2.7.0.dev20250220+cu128 与 torchvision==0.19.1+cu124 时,pip 直接报 conflicting dependencies,因为 torchvision 0.19.1+cu124 依赖 torch==2.4.1+cu124。
- 混用不同索引(一个是 cu124 索引、一个是 nightly/cu128 索引)会让 pip 解析出跨 CUDA 版本的三件套。
解决步骤
已按「最可能有效」排序。请从上往下做,每做完一步用「验证」确认,不要一次改五处。
- 分别打印三个包各自的 CUDA 编译版本,找出不一致的那个torch.version.cuda 是 torch 的编译 CUDA 版本,torchvision 与 torchaudio 也各自带 version.cuda 属性,三者打印出来对比即可定位。.\python_embeded\python.exe -c "import torch, torchvision, torchaudio; print(torch.__version__, torch.version.cuda); print(torchvision.__version__, torchvision.version.cuda); print(torchaudio.__version__, torchaudio.version.cuda)"
- 把三件套作为一组从同一个索引整体重装,不要让 pip 自己解析先全部卸载再一次性从同一索引安装,避免 pip 为满足某个旧依赖而保留旧版本。官方给出的 NVIDIA 安装命令即三件套同时指定同一个 cu 索引。.\python_embeded\python.exe -m pip uninstall -y torch torchvision torchaudio.\python_embeded\python.exe -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128.\python_embeded\python.exe -m pip check
- 确认三件套的版本配对表,避免下次再装错同一个发布批次的 torch/torchvision/torchaudio 版本号是固定搭配(例如 PyTorch 论坛帖里出现的错误就是 torch 2.7 nightly + torchvision 0.19.1 这种跨批次组合)。查 torch-torchvision 的配对关系应以 PyTorch 官方 index 页面上同时列出的版本为准,不要凭记忆写版本号。安装完成后用 pip check 检查是否还有 broken requirements。.\python_embeded\python.exe -m pip check
验证是否修好
三个包的 CUDA 版本号完全一致,ComfyUI 能正常启动并出图;pip check 输出 No broken requirements found。
补充说明
若你的环境完全不需要 torchaudio,有些社区做法是直接卸载 torchaudio 来绕开校验;但 ComfyUI 官方依赖里包含 torchaudio,卸载后需自行确认没有节点引用它。[未核实] 具体哪些节点强依赖 torchaudio 未逐一验证。
来源
按可信度排列:官方 issue / 官方文档 > 节点仓库 issue > 社区帖 > 中文社区文章。
链接以纯文本给出(本站不做站外跳转),需要核对时请自行复制到浏览器打开。
- [142] (官方 issue) ComfyUI fails to start with a RuntimeError due to a CUDA version misma https://github.com/Comfy-Org/ComfyUI/issues/14384
- [140] (社区) Pytorch support for sm120 - PyTorch Forums https://discuss.pytorch.org/t/pytorch-support-for-sm120/216099
- [143] (社区) [Bug]: Detected that PyTorch and torchvision were compiled with differ https://github.com/Comfy-Org/ComfyUI/issues/10331
本条的可靠性边界
下面这些位置带
[未核实] 标记,是采集时没找到一手来源的部分,请自行验证:
- 补充说明
这条报错要用到的东西
按本条报错所属的类别(PyTorch、CUDA 运行库与加速库冲突)列出站内相关的下载包与板块入口。 它们不是「必须下载才能修好」,而是这一类问题里最常要动到的东西;具体怎么做,以上面的解决步骤为准。
环境与依赖配置包依赖版本组合清单 / 环境自检脚本说明
待挂载
同一类别的其他条目
【056】启动或首次生成时报 AssertionError: Torch not compiled with CUDA enabled(装成了 CPU 版 torch)
有来源
【057】50 系显卡第一次卷积就崩:CUDA error: no kernel image is available for execution on the device
含未核实
【059】节点执行时报 Could not run 'torchvision::nms' / operator torchvision::nms does not exist
含未核实
【060】自定义节点装完 / 更新依赖后 torch 被偷换成 CPU 版(依赖漂移)
有来源
【061】装完 xformers 后 torch 被降级、加速库反而让 ComfyUI 崩(xformers 陷阱)
含未核实
这个解法对你有效吗
记录只存在你自己的浏览器里,不需要注册账号。
知仓学习社