报错
056
PyTorch、CUDA 运行库与加速库冲突
有来源可查
启动或首次生成时报 AssertionError: Torch not compiled with CUDA enabled(装成了 CPU 版 torch)
报错原文(原样)
File "...\torch\cuda\__init__.py", line 310, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
检索关键词
AssertionError: Torch not compiled with CUDA enabled、Torch not compiled with CUDA enabled、torch.cuda.is_available() False、2.x.x+cpu、Torch not compiled with CUDA enabled on 5060ti
先看这一句
ComfyUI 能启动,但一点生成就报 Torch not compiled with CUDA enabled,或者启动日志里显示设备是 CPU、生成速度慢到几分钟一张;torch.__version__ 结尾带 +cpu。
适用版本 全版本通用。RTX 50 系(Blackwell / sm_120)必须用 cu128 或更高的 wheel;cu124/cu126 这类旧轮子在 50 系上即使装上也会在第一次卷积时报 no kernel image 错误。
·
核实日期 2026-09-26
·
状态 已核实
适用环境:Windows 便携版、秋叶/绘世整合包、ComfyUI Desktop、Linux + 云 GPU、全部主流环境
现象与触发场景
常见触发场景:
- 用普通 pip install torch 装过依赖,PyPI 在 Windows 上默认给的是 CPU 版 wheel
- 装完某个自定义节点后,节点的 requirements.txt 里写了 torch>=2.x,pip 把原来的 CUDA 版 torch 覆盖成 CPU 版
- 跑过一次 pip install -r requirements.txt 或 ComfyUI-Manager 的“安装依赖”之后突然变 CPU
根因
- PyTorch 的 CPU wheel 与 CUDA wheel 是两个完全不同的二进制,CPU wheel 里没有任何 GPU kernel,装驱动、装 CUDA Toolkit、设环境变量都无法让它支持 CUDA,只能换 wheel。
- 在 Windows 上 PyPI 默认提供的是 CPU-only 的 torch;CUDA 版只存在于 PyTorch 官方索引(download.pytorch.org/whl/cuXXX),所以任何不带 --index-url 的 pip install torch 都会把 CUDA 版挤掉。
- 官方 README 已明确指出:遇到该错误的处理办法就是卸载 torch 并从 CUDA 索引重装。
解决步骤
已按「最可能有效」排序。请从上往下做,每做完一步用「验证」确认,不要一次改五处。
- 先用便携版自带解释器确认是不是 CPU wheel便携版有自己的 Python,在 ComfyUI_windows_portable 目录下必须显式调用 python_embeded\python.exe,否则你测的是系统 Python,看到的结果和 ComfyUI 实际用的环境无关。输出的版本号结尾若是 +cpu 或 cuda.is_available() 为 False,就确认是 CPU wheel。.\python_embeded\python.exe -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0))"
- 卸载 CPU 版 torch 三件套,从 PyTorch 官方索引重装 cu128先卸载再安装,避免 pip 认为“已满足依赖”而保留 CPU 版。50 系显卡要装 cu128(或更高)而非 cu124/cu126,并且要用 --index-url 而不是 --extra-index-url,这样 pip 只从 PyTorch 索引取包,不会回退到 PyPI 的 CPU 版。.\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
- 给 ComfyUI-Manager 加防覆盖配置,避免自定义节点再次把 torch 换回 CPU 版在 ComfyUI-Manager 的 config.ini 中把 torch 三件套加入 downgrade_blacklist,Manager 就不会在装节点依赖时降级/替换它们;pip_auto_fix.list 可以用来在启动时自动恢复指定版本的包。config.ini 在 v0.3.76+ 位于 <USER_DIRECTORY>/__manager/,老版本位于 <USER_DIRECTORY>/default/ComfyUI-Manager/。downgrade_blacklist = torch, torchvision, torchaudio
验证是否修好
重跑第一步的命令,应当看到版本号带 +cu128(不含 +cpu)、torch.version.cuda 是一个真实 CUDA 号、is_available() 为 True 且打印出显卡名(如 NVIDIA GeForce RTX 5060 Ti);随后重启 ComfyUI,启动日志里设备应为 cuda:0 而不是 cpu。
补充说明
若显示 +cu128 且 is_available() 为 True 但 ComfyUI 仍报同样的错,说明机器上有两个 Python 环境,ComfyUI 启动的是另一个环境,需要检查 run_nvidia_gpu.bat 指向的解释器路径。
来源
按可信度排列:官方 issue / 官方文档 > 节点仓库 issue > 社区帖 > 中文社区文章。
链接以纯文本给出(本站不做站外跳转),需要核对时请自行复制到浏览器打开。
- [6] (官方文档) How to Troubleshoot and Solve ComfyUI Issues https://docs.comfy.org/troubleshooting/overview
- [136] (官方文档) Common Issues and Solutions - ComfyUI https://mintlify.wiki/Comfy-Org/ComfyUI/guides/common-issues
- [137] (官方 issue) AssertionError: Torch not compiled with CUDA enabled on 5060ti · Issue https://github.com/Comfy-Org/ComfyUI/issues/7826
- [138] (社区) ComfyUI 'Torch not compiled with CUDA enabled'? Every Fix That Works o https://dev.to/jovan_chan_9500711396d4e6/comfyui-torch-not-compiled-with-cuda-enabled-every-fix-that-works-on-windows-linux-and-mac-556m
这条报错要用到的东西
按本条报错所属的类别(PyTorch、CUDA 运行库与加速库冲突)列出站内相关的下载包与板块入口。 它们不是「必须下载才能修好」,而是这一类问题里最常要动到的东西;具体怎么做,以上面的解决步骤为准。
环境与依赖配置包依赖版本组合清单 / 环境自检脚本说明
待挂载
同一类别的其他条目
【057】50 系显卡第一次卷积就崩:CUDA error: no kernel image is available for execution on the device
含未核实
【058】启动直接崩:torch / torchvision / torchaudio 三者 CUDA 版本不一致
含未核实
【059】节点执行时报 Could not run 'torchvision::nms' / operator torchvision::nms does not exist
含未核实
【060】自定义节点装完 / 更新依赖后 torch 被偷换成 CPU 版(依赖漂移)
有来源
【061】装完 xformers 后 torch 被降级、加速库反而让 ComfyUI 崩(xformers 陷阱)
含未核实
这个解法对你有效吗
记录只存在你自己的浏览器里,不需要注册账号。
知仓学习社