ComfyUI 'Torch not compiled with CUDA enabled'? Every Fix That Works on Windows, Linux, and Mac (2026)
TL;DR: This error means the PyTorch you have installed is the CPU-only build — it literally has no CUDA code compiled in, so it can’t see your GPU even though the driver is fine. The fix is never to reinstall CUDA or your GPU driver; it’s to uninstall the CPU torch and reinstall the matching cu12x wheel from PyTorch’s own index. On an RTX 50-series card you need the cu128 build specifically.
What you’ll be able to do after this guide:
- Confirm in 10 seconds whether your
torchis the CPU build or the GPU build - Reinstall the correct CUDA wheel in both ComfyUI portable and a manual venv install
- Pick the right
cu124/cu126/cu128wheel for your exact GPU (and know why RTX 50-series is different)
Honest take: 90% of the time this happens because a custom node ran
pip installsomething, pip pulledtorchas a dependency, and on Windows the default PyPItorchwheel is CPU-only. You didn’t break CUDA — pip quietly swapped your good GPU build for a smaller CPU one. Reinstalling the right wheel takes about three minutes.
What the error actually means
When ComfyUI starts (or the first time it tries to move a model to the GPU) you get a traceback ending in:
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
Read it literally: the PyTorch binary you installed was built without CUDA support. PyTorch ships in separate flavors — a CPU-only wheel and several CUDA wheels (cu124, cu126, cu128, etc.). The CPU wheel is a completely different binary with no GPU kernels in it. No driver update, no CUDA Toolkit install, and no environment variable will add CUDA to a CPU wheel. You have to replace the wheel.
This is different from a driver problem. If your NVIDIA driver were missing, nvidia-smi would fail. Run it in a terminal:
$ nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 581.xx Driver Version: 581.xx CUDA Version: 12.8 |
| 0 NVIDIA GeForce RTX 4070 ... |
+-----------------------------------------------------------------------------+
If nvidia-smi shows your card, your driver is fine and the problem is 100% on the PyTorch side. (The “CUDA Version: 12.8” line here is the maximum CUDA the driver supports, not the version PyTorch needs — a common point of confusion.)
Step 1: Confirm you actually have the CPU build
Before changing anything, prove the diagnosis. ComfyUI portable ships its own Python under python_embeded, so use that exact interpreter — not whatever python resolves to in your PATH. From the ComfyUI_windows_portable folder:
.\python_embeded\python.exe -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"
A CPU build prints something like this — note the +cpu suffix and False:
2.8.0+cpu
False
A working GPU build prints a CUDA tag (+cu128) and True:
2.8.0+cu128
True
If you see +cpu or False, this guide fixes you. If you see +cu128 and True but ComfyUI still throws the error, you have two Python environments and ComfyUI is launching the wrong one — skip to the “Two-environments trap” section below.
For a manual (cloned-repo) install, run the same one-liner but activate your venv first, or call the venv’s Python directly:
# Windows venv
.\venv\Scripts\python.exe -c "import torch; print(torch.__version__, torch.cuda.is_available())"
# Linux/Mac venv
./venv/bin/python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
Step 2: Pick the right CUDA wheel for your GPU
This is the part people get wrong. The wheel tag (cu124, cu126, cu128) is the CUDA runtime bundled inside the PyTorch wheel. It does not need to match a CUDA Toolkit on your machine — the wheel is self-contained. What it does need to match is your GPU architecture.
| Your GPU | Architecture | Wheel to install | Minimum PyTorch |
|---|---|---|---|
| RTX 50-series (5060 Ti / 5070 / 5080 / 5090) | Blackwell, sm_120 | cu128 | 2.7.0 |
| RTX 40-series (4060 Ti / 4070 / 4080 / 4090) | Ada, sm_89 | cu124, cu126, or cu128 | any current |
| RTX 30-series (3060 / 3080 / 3090) | Ampere, sm_86 | cu124, cu126, or cu128 | any current |
The RTX 50-series is the trap. Blackwell’s sm_120 compute capability was only added to stable PyTorch in 2.7.0, which shipped the first pre-built CUDA 12.8 wheels with native Blackwell support. If you install an older cu124 wheel on an RTX 5090, you’ll get past this error only to hit CUDA error: no kernel image is available for execution on the device — the sibling problem of running a too-old wheel on a too-new GPU. On a 50-series card, use cu128 and PyTorch 2.7.0 or newer, full stop.
For RTX 30/40-series, any of cu124/cu126/cu128 works; cu128 is the safe current default since it’s what ComfyUI’s own portable builds ship now.
Step 3: Reinstall — ComfyUI portable (Windows)
From inside the ComfyUI_windows_portable directory, uninstall the bad trio first so pip doesn’t try to “keep” the CPU build:
.\python_embeded\python.exe -m pip uninstall -y torch torchvision torchaudio
Then install the CUDA wheel from PyTorch’s index. For an RTX 50-series card:
.\python_embeded\python.exe -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
Note --index-url, not --extra-index-url. Using --index-url forces pip to pull only from the PyTorch index, which guarantees you get the GPU wheel instead of pip silently falling back to the CPU-only one on PyPI. That fallback is the exact mechanism that broke you in the first place.
Re-run the check from Step 1. You want +cu128 and True. Then launch ComfyUI and the error is gone.
If the download is slow or stalls — the CUDA wheels are large, often 2.5 GB-plus because they bundle the CUDA runtime, cuDNN, and NCCL — let it finish; that size is normal and is the whole reason PyPI defaults to the small CPU wheel on Windows in the first place.
Step 4: Reinstall — manual / venv install (Windows, Linux)
If you cloned the repo and run inside a venv, activate it, then do the same uninstall/reinstall:
# activate first
source venv/bin/activate # Linux/Mac
.\venv\Scripts\activate # Windows
pip uninstall -y torch torchvision torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
ComfyUI also publishes a maintained requirements path; if you’d rather follow the project’s pinned versions, the official install docs list the current recommended cu128 command for your platform. Either way the principle is identical: uninstall CPU torch, install the cu128 wheel from the PyTorch index.
Why this keeps happening (and how to stop it)
On Windows and macOS, the torch package on the default Python Package Index (PyPI) is the CPU-only wheel. PyPI serves the lightweight CPU binary by default to those platforms; the CUDA-enabled wheels live only on PyTorch’s own download index. So the moment anything runs a plain pip install torch — or installs a package that lists torch as a dependency without pinning the CUDA build — pip happily grabs the CPU wheel from PyPI and overwrites your working GPU install.
The usual culprit is a custom node. You install some shiny new node, its requirements.txt says torch>=2.x, ComfyUI’s “install dependencies” step runs, pip decides your current torch doesn’t satisfy something, and it reinstalls from PyPI — CPU build. ComfyUI was fine yesterday and broken today, and you “didn’t change anything.” You did: a node did.
Two habits prevent the relapse:
- When installing custom-node requirements, never let pip touch torch. If a node’s requirements pull torch, install the node’s other deps and reinstall the
cu128torch afterward, or edit the requirements to drop the torch pin. - Keep the reinstall command in a
.bat/.shfile next to ComfyUI. When it breaks again, you re-run one script instead of re-reading this article.
The two-environments trap
If Step 1 says True but ComfyUI still errors, you have more than one Python and ComfyUI is starting the wrong interpreter. This is common when you’ve installed system Python and use the portable build, or have multiple venvs. ComfyUI portable should always launch via its bundled Python — check that your launch script calls .\python_embeded\python.exe -s ComfyUI\main.py and not a bare python main.py. Whatever interpreter prints the traceback is the one to fix; run the Step 1 check with that exact python.exe path to confirm which environment ComfyUI is really using.
Apple Silicon and AMD: this error means something else
If you’re on a Mac (M1–M4) or an AMD GPU and you see “Torch not compiled with CUDA enabled,” do not try to install a cu128 wheel — there is no CUDA on those platforms at all.
- Apple Silicon: PyTorch uses the MPS backend, not CUDA. The error usually means a node hard-coded
.cuda()ordevice="cuda". ComfyUI itself runs on Mac with MPS; you don’t install a CUDA wheel, you fix or replace the node forcing CUDA. Launching with--cpuis a temporary workaround that disables GPU acceleration entirely. - AMD: On Linux you need the ROCm build of PyTorch (
--index-url https://download.pytorch.org/whl/rocm6.x), not acu128wheel. On Windows, AMD users typically go through a DirectML or ZLUDA path. See our ROCm 7.2 on Ubuntu setup guide for the AMD-specific install. For Intel Arc, the GPU path is different again — covered in our Intel Arc B580 for local AI guide.
If it still fails after a correct reinstall
A few less-common causes, in order of likelihood:
- Python version too new for the wheel. Brand-new Python releases sometimes lack matching torch wheels for a week or two. ComfyUI portable pins a known-good Python, which sidesteps this — another reason to use it.
- A stale
torchcached in a second site-packages. Runpip list | findstr torch(Windows) orpip list | grep torchand confirm only one torch is installed, with the+cu128local version when you query it. - You’re on a 50-series card with an old wheel and now see
no kernel image is availableinstead. That’s thesm_120mismatch — reinstallcu128with PyTorch ≥ 2.7.0. - Out of disk space mid-install, leaving a half-written torch. Uninstall again and reinstall cleanly.
For the related “it loads but crashes with out-of-memory,” that’s a separate problem with separate fixes — see CUDA Out of Memory on Local AI: every fix that works. And if your LLM runner (not ComfyUI) is ignoring the GPU, the Ollama-specific version is Ollama Not Using GPU? Fix CPU-only inference.
No GPU at all? You have two real options
If you’re hitting this because you don’t actually have an NVIDIA GPU yet, you have two honest paths. Run ComfyUI with --cpu — it works, but expect a 512×512 SDXL image to take minutes rather than seconds, which gets old fast. Or rent a GPU by the hour: a cloud RTX 4090 or 5090 on a service like RunPod runs the real CUDA build with zero local setup, which is a reasonable way to decide whether a local card is worth buying before you spend on one. If you’re weighing rent-vs-buy, we did the full math in RunPod vs Local GPU: when to rent and when to buy. And if you’re picking a first card for image generation specifically, the GPU buying guide for local AI covers the $300–$3,000 range. For building local coding agents instead of image models, our sister site aicoderscope.com goes deep on that side.
FAQ
Do I need to install the CUDA Toolkit to fix this?
No. The PyTorch CUDA wheel bundles its own CUDA runtime. You only need a recent NVIDIA driver (which nvidia-smi confirms). Installing a separate CUDA Toolkit doesn’t fix a CPU-only torch and isn’t required for ComfyUI.
My nvidia-smi says “CUDA Version: 12.8” — does that mean I need cu128?
Not directly. That number is the maximum CUDA your driver supports, not the wheel you need. A driver reporting 12.8 can run cu124, cu126, or cu128 wheels fine. The wheel choice is driven by your GPU architecture (use the table above), not by the driver’s reported number.
Why did it work yesterday and break today?
Almost always a custom node ran pip install and pip replaced your GPU torch with the CPU wheel from PyPI. Reinstall the cu128 wheel and avoid letting node requirements reinstall torch.
Is --extra-index-url or --index-url correct?
Use --index-url https://download.pytorch.org/whl/cu128. --extra-index-url leaves PyPI in the mix, so pip can still pick the CPU wheel. --index-url forces the PyTorch index only.
I have an RTX 5090 and now get “no kernel image is available.” Different error?
Same root cause, opposite direction: your wheel is too old for Blackwell’s sm_120. Install cu128 with PyTorch 2.7.0 or newer.
Sources
- AssertionError: Torch not compiled with CUDA enabled — ComfyUI Issue #2427
- Torch not compiled with CUDA enabled after update — ComfyUI Issue #11575
- System Requirements — ComfyUI Official Documentation
- PyTorch 2.7 Release (Blackwell support, CUDA 12.8 wheels) — PyTorch Blog
- Official support for sm_120 (RTX 50-series / Blackwell) in stable PyTorch — PyTorch Issue #164342
- Using uv with PyTorch (PyPI serves CPU-only wheels on Windows/macOS) — Astral docs
- Running PyTorch on RTX 5090 and 5080 GPUs — SaladCloud
Last updated June 18, 2026. PyTorch wheel tags and version numbers change; verify the current cu12x command on the official PyTorch install page before running it.
Was this article helpful?
Thanks for the feedback — it helps improve future articles.
Need hands-on help?
I offer 1-on-1 technical consulting for local AI setup, GPU selection, and AI coding tool configuration — same topics covered on this site.
Book a session — $49 / hour →