LogoWonderful Launcher
  • Home
  • Pricing
  • Docs
  • Download

No module named 'torch' in ComfyUI

VerifiedHigh riskTested on Windows 10, Windows 11 | Launcher 1.x | ComfyUI portableLast verified 2026-06-29

Fix ModuleNotFoundError: No module named 'torch' in ComfyUI portable, venv, and managed installs, then verify the repaired Torch build still has CUDA.

ComfyUI stops with ModuleNotFoundError: No module named 'torch' (also seen as No module named torch / ComfyUI torch missing) when the Python that launched ComfyUI cannot import Torch. This is a core runtime failure, not a warning.

Fix it by installing a CUDA wheel into that exact Python, then verifying the build is not CPU-only.

.\python_embeded\python.exe -s -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cuXXX

Replace cuXXX with the CUDA wheel tag for your supported PyTorch build from the official PyTorch selector. Then confirm torch.version.cuda is not None and torch.cuda.is_available() is True before relaunching.

Triage

What you seeMeaningFirst action
ModuleNotFoundError: No module named 'torch'Torch is missing from the Python that launched ComfyUIInstall Torch in the active ComfyUI Python
pip show torch works in system Python but ComfyUI still failsInstalled into the wrong PythonUse python_embeded\python.exe or the active venv
import torch works, but the version ends in +cpuYou repaired the import with a CPU-only wheelReplace it with a matching CUDA wheel
Next error becomes No module named 'torchvision' / 'torchaudio'Adjacent core packages are still missingRepair those next in the same environment
torch.cuda.is_available() is FalseGPU build mismatch, wrong wheel, or driver problemGo to the CUDA verification step
AssertionError: Torch not compiled with CUDA enabledInstalled, but CPU-only or wrong CUDA buildTorch not compiled with CUDA enabled

Step 1: Use the Python that actually starts ComfyUI

For Windows portable:

.\python_embeded\python.exe -s -c "import sys; print(sys.executable)"
.\python_embeded\python.exe -s -m pip show torch torchvision torchaudio

For a manual venv:

.\venv\Scripts\activate
python -c "import sys; print(sys.executable)"
python -m pip show torch torchvision torchaudio

For ComfyUI Desktop or another managed launcher, use the app's own terminal or environment tools. Do not assume python_embeded exists.

Step 2: Install Torch in the active environment

Choose the CUDA wheel for your GPU, driver, Python version, and supported PyTorch build from the official PyTorch selector. Do not begin with a bare pip install torch: it can restore the import with a CPU-only wheel.

For Windows portable, run the selected command through the embedded Python:

.\python_embeded\python.exe -s -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cuXXX

For a manual venv, activate it first, then use the same --index-url pattern with python -m pip. Replace cuXXX with the CUDA wheel tag for your supported build.

Step 3: Verify you did not install CPU Torch

Run this in the same Python that launches ComfyUI:

.\python_embeded\python.exe -s -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'no cuda')"

Output ending in +cpu with None False is a CPU-only build. Re-run the Step 2 CUDA-wheel command. Do not add a regional package mirror to the primary command; solve regional network access separately and verify package provenance.

If Torch imports but CUDA still fails, continue with Torch Not Compiled With CUDA Enabled in ComfyUI.

Step 4: Restart and read the next first error

.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build

In a damaged portable environment the next blocker is often another core package (safetensors, packaging, numpy, torchvision, torchaudio). Fix the next first blocker in the same Python instead of switching to random package commands. If the environment keeps drifting from one core package to another, use the one-package-at-a-time portable repair runbook.

What not to do

  • do not install Torch into system Python if ComfyUI launches from python_embeded or a venv
  • do not assume import torch success means CUDA is repaired
  • do not reinstall CUDA Toolkit first for a normal wheel-based ComfyUI setup
  • do not start with pip install -r while you are still learning what broke
  • do not reinstall custom nodes until the core runtime is green again

Related Guides

  • Torch Not Compiled With CUDA Enabled in ComfyUI
  • Repair ComfyUI Portable Dependencies One Missing Module At A Time
  • comfyui-frontend-package is not installed in ComfyUI
  • ComfyUI Dependency Conflicts
  • Installed Custom Nodes and Broke ComfyUI? Recover Without Reinstalling

Source References

  • PyTorch Start Locally installer

Start free with Wonderful Launcher if this affects your real ComfyUI environment. It keeps launcher-native repair, task logs, and runtime checks in one place; credits are only for image generation and metered tools.

Download Wonderful LauncherSee credit packages

Did this fix your issue?

Your answer helps prioritize verified ComfyUI repairs.

Table of Contents

Triage
Step 1: Use the Python that actually starts ComfyUI
Step 2: Install Torch in the active environment
Step 3: Verify you did not install CPU Torch
Step 4: Restart and read the next first error
What not to do
Related Guides
Source References