If you’ve seen the error “Torch is not compiled with CUDA support” in ComfyUI, you know the frustration: your RTX 4090 sits idle while your CPU melts trying to generate a single image. The good news? This error has a straightforward fix. The problem isn’t your GPU, your drivers, or ComfyUI itself — it’s that PyTorch was installed in CPU-only mode. PyTorch, the deep learning library that powers ComfyUI, ships in two versions: one compiled with NVIDIA CUDA support (which unlocks GPU acceleration) and one without (which forces everything onto your CPU). When you install torch the wrong way, you get the CPU version by default, and ComfyUI has no choice but to process every image on your processor instead of your graphics card.
This guide walks you through diagnosing the problem, identifying your CUDA version, and performing the reinstall that actually works. By the end, you’ll understand why this happens and how to prevent it in the future.
Quick Reference: At a Glance
| Symptom | Cause | Fix |
|---|---|---|
| ”Torch is not compiled with CUDA” error | PyTorch installed without --index-url flag | Reinstall with correct CUDA index |
torch.cuda.is_available() returns False | CPU-only build installed | Run pip install torch --index-url https://download.pytorch.org/whl/cu121 |
| GPU sits idle during generation | CUDA not detected by PyTorch | Verify venv is active, check CUDA version with nvidia-smi |
Version string ends in +cpu | CPU-only build confirmed | Uninstall and reinstall with GPU index |
Why This Error Happens
PyTorch is massive — we’re talking GPU-specific compiled code baked directly into the library during the build process. When NVIDIA releases a new CUDA Toolkit version, the PyTorch team rebuilds the library against that version and publishes it to their own download server at download.pytorch.org. This is not the default PyPI repository.
Here’s where most people trip up: run pip install torch without specifying a custom download index, and pip defaults to PyPI, which only hosts the CPU-only build. That CPU version is smaller, downloads faster, and works on literally any machine — so it’s the default. The GPU-enabled versions live elsewhere, behind a specific --index-url flag that most users never know to add.
The result: thousands of us install PyTorch, assume it’s working, fire up ComfyUI, and wonder why the expensive GPU isn’t being used. The ComfyUI CUDA error becomes a daily frustration because the root cause — a missing flag during installation — goes undiagnosed.
💡 Tip: PyTorch defaults to CPU-only when installed without the
--index-urlflag. You must explicitly tell pip to download the CUDA-enabled build.
Diagnosing the Problem: Four Quick Tests
Before you reinstall anything, confirm that CUDA support is actually the issue. These tests take 60 seconds and will tell you exactly what’s wrong.
Test 1: Activate Your Virtual Environment
This is the most commonly missed step. If you’re running ComfyUI, you’re almost certainly using a Python virtual environment. You must activate it before running any diagnostic commands.
Windows:
venv\Scripts\activate
macOS/Linux:
source venv/bin/activate
You should see the environment name in parentheses at the start of your command prompt. If you don’t see it, you’re running commands in the system Python, not your ComfyUI environment.
Test 2: Check if CUDA is Available
python -c 'import torch; print(torch.cuda.is_available())'
If this prints True, PyTorch can see your GPU and the problem is elsewhere (possibly a wrong CUDA index during installation, but the library itself is functional). If it prints False, you’ve confirmed it: PyTorch was installed without CUDA support, and ComfyUI not detecting GPU is the expected result.
Test 3: Check the PyTorch Version String
python -c 'import torch; print(torch.__version__)'
Look at the output carefully. If it ends in +cpu (like 2.1.0+cpu or 2.0.1+cpu), that’s a dead giveaway — you have the CPU-only build. A correct CUDA build will show something like 2.1.0 with no suffix, or possibly 2.1.0+cu121.
Test 4: Verify Your GPU Driver Works
nvidia-smi
This command displays your GPU(s) with memory info. If it works, your hardware and drivers are fine. If it fails, CUDA Toolkit or drivers aren’t installed on your system — that’s a separate problem from PyTorch installation.
📌 Keep in mind: These four tests take one minute and will tell you whether the problem is PyTorch installation, CUDA version mismatch, or a hardware/driver issue.
Identifying Your CUDA Version
Before reinstalling PyTorch, you need to know which CUDA version your system supports. This determines which build to download.
Method 1: nvidia-smi (Easiest)
Run nvidia-smi and look at the top-right corner of the output. You’ll see a line like:
CUDA Version: 12.4
Note this number — this is the CUDA version your GPU drivers support, and it’s the one you need for PyTorch.
Method 2: CUDA Compiler
nvcc --version
This shows the CUDA Toolkit version installed locally. Note that nvidia-smi shows the maximum version supported by your driver, which is the relevant one for installing PyTorch.
What If Neither Works?
If both commands fail, CUDA probably isn’t installed at all. You’ll need to download and install the CUDA Toolkit from NVIDIA’s developer site before proceeding. This is a separate, more involved process.
The PyTorch Installation Index Reference
PyTorch publishes different builds for different CUDA versions. Use this table to find the correct --index-url for your setup:
| CUDA Version | Index URL | GPU Examples | When to Use |
|---|---|---|---|
| 12.4 / 12.1 | https://download.pytorch.org/whl/cu121 | RTX 40-series (4090, 4080, 4070, etc.) | Recommended for newest NVIDIA GPUs |
| 11.8 | https://download.pytorch.org/whl/cu118 | RTX 30-series, RTX 20-series, GTX 1080 Ti | Most common for mid-range and older cards |
| 11.7 | https://download.pytorch.org/whl/cu117 | GTX 1080, older systems | Legacy support only |
Rule of thumb: If nvidia-smi shows a CUDA version newer than any index listed here (PyTorch’s published wheel indexes lag behind the newest CUDA Toolkit releases), use the newest index available — check download.pytorch.org for the current list before assuming an index exists.
The Fix: Reinstalling PyTorch with CUDA
Step 1: Clean the Old Installation (Optional but Recommended)
Activate your virtual environment, then uninstall the CPU-only build:
pip uninstall torch torchvision torchaudio -y
This removes the broken installation cleanly. You can skip this step if you prefer, but it prevents version conflicts.
Step 2: Reinstall with the Correct Index
Still in your activated virtual environment, run the install command for your CUDA version. For CUDA 12.1 (the most common for recent GPUs):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
For CUDA 11.8:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
For CUDA 11.7:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
This download will take 5–10 minutes. PyTorch with CUDA support is large (around 2–3 GB). Don’t interrupt it.
Step 3: Verify the Installation
Once the install finishes, run:
python -c 'import torch; print(torch.cuda.is_available(), torch.version.cuda)'
You should see output like:
True 12.1
If you see True and a version number, CUDA is working. If you see False, something went wrong — recheck your CUDA version and try the install again with the correct index.
👉 Quick takeaway: The three-step reinstall (clean, install with
--index-url, verify) takes 15 minutes and resolves the “torch not compiled with CUDA” error in almost all cases.
Why This Problem Persists
ComfyUI Desktop (the standalone app) doesn’t have this issue because it ships with a pre-configured Python environment and PyTorch already compiled for CUDA. Manual GitHub installs, dependency updates run without the index flag, and environments inherited from other projects all fall into the same trap.
Many users assume pip install torch will “just work” the same way it does for other packages. It doesn’t — PyTorch requires explicit index specification for GPU support. This is a usability quirk of PyTorch, not a ComfyUI bug. Understanding this distinction helps you avoid the problem in the future when updating dependencies or setting up new environments.
Special Cases
Windows Users
Windows is where this error strikes most often. Many users run pip install torch in PowerShell or Command Prompt without thinking, get the CPU build, and only notice when ComfyUI crawls. Always activate your venv first (check for the parentheses in your prompt), then use the indexed install command. The --index-url flag is non-negotiable on Windows.
macOS with Apple Silicon (M1, M2, M3)
Apple Silicon Macs cannot use NVIDIA CUDA at all. They need Metal Performance Shaders instead, which requires a completely different PyTorch setup. If you have an M-series Mac, search for “PyTorch Metal macOS” — the installation process is different and this guide doesn’t apply.
Linux
Linux distributions usually handle CUDA more cleanly than Windows. If you see this error on Linux, 99% of the time it’s simply a missing --index-url flag. Run the reinstall command for your CUDA version and it should resolve immediately.
Common Errors During Reinstallation
“No module named torch” after reinstall: The install failed or you’re running Python in the wrong environment. Confirm your venv is active (check the parentheses), then rerun the install command.
“CUDA out of memory” during generation: This is not the same error. It means PyTorch successfully detected your GPU, but the image is too large for your VRAM. Reduce the image resolution, enable memory-efficient settings, or use quantization.
“CUDA out of memory” even on a GPU with 24GB+ VRAM: This is unrelated to the CUDA version match — it means the model or resolution genuinely exceeds available VRAM. Reduce resolution, use --lowvram, or switch to a quantized (GGUF) model.
FAQ
Q: How do I know which CUDA version I have installed?
A: Run nvidia-smi in a terminal. The CUDA version appears in the top-right corner (e.g., CUDA Version: 12.4). You can also use nvcc --version, though nvidia-smi shows the maximum version supported by your driver, which is the relevant one for installing PyTorch.
Q: I reinstalled PyTorch with CUDA and it still doesn’t detect the GPU. What’s wrong?
A: Check that you installed into the correct virtual environment. Activate the venv first (source venv/bin/activate on Linux, venv\Scripts\activate on Windows) before running pip install. If you install without the venv active, it goes into the system Python, not ComfyUI’s.
Q: Can I use ComfyUI with AMD or Intel Arc?
A: Yes. For AMD, install PyTorch with ROCm (--index-url https://download.pytorch.org/whl/rocm5.7). For Intel Arc, use a ComfyUI fork with OpenVINO or DirectML support. Performance is lower than NVIDIA but functional.
Q: Why doesn’t ComfyUI Desktop have this problem but the manual install does?
A: ComfyUI Desktop ships its own Python environment with PyTorch+CUDA correctly preinstalled. In manual installs, running pip install torch without specifying an index downloads the CPU-only version from PyPI by default.
Keep Reading
If you’re setting up ComfyUI from scratch, our full Windows install guide covers the correct CUDA/PyTorch pairing from the start, which avoids this error entirely. Once CUDA is working, the next common snag is a custom node dependency — see our guide on fixing Import Failed errors if you hit one.
🏆 Our Recommendation
If you’re seeing the “torch not compiled with CUDA” error, follow these steps in order:
- Activate your virtual environment — this is the most commonly missed step.
- Run
nvidia-smito confirm your CUDA version (look at the top-right corner). - Uninstall the CPU build with
pip uninstall torch torchvision torchaudio -y. - Reinstall with the correct index using the table above (cu121 for most modern GPUs, cu118 for older cards).
- Verify with
python -c 'import torch; print(torch.cuda.is_available())'.
If you’re on Windows and this is your first time, take extra care with the venv activation step — the parentheses in your command prompt are your confirmation. If you’re on an M-series Mac, this guide doesn’t apply; search for PyTorch Metal instead. If you’re on Linux, the process is identical but usually faster. After reinstalling, restart ComfyUI completely and your GPU should be detected automatically.
Next steps in ComfyUI
Getting started
FAQ
- How do I know which CUDA version I have installed?
- Run nvidia-smi in a terminal. The CUDA version appears in the top-right corner (e.g. CUDA Version: 12.4). You can also use nvcc --version, though nvidia-smi shows the maximum version supported by your driver, which is the relevant one for installing PyTorch.
- I reinstalled PyTorch with CUDA and it still doesn't detect the GPU. What's wrong?
- Check that you installed into the correct virtual environment. Activate the venv first (source venv/bin/activate on Linux, venv\Scripts\activate on Windows) before running pip install. If you install without the venv active, it goes into the system Python, not ComfyUI's.
- Can I use ComfyUI with AMD or Intel Arc?
- Yes. For AMD, install PyTorch with ROCm (--index-url https://download.pytorch.org/whl/rocm5.7). For Intel Arc, use a ComfyUI fork with OpenVINO or DirectML support. Performance is lower than NVIDIA but functional.
- Why doesn't ComfyUI Desktop have this problem but the manual install does?
- ComfyUI Desktop ships its own Python environment with PyTorch+CUDA correctly preinstalled. In manual installs, running 'pip install torch' without specifying an index downloads the CPU-only version from PyPI by default.