LogoWonderful Launcher
  • Product
  • Pricing
  • Solutions
  • Docs
  • Blog
  • Get Help
  • Download
No Module NamedComfyUI Dependency Conflicts: Fix Without ReinstallingTorch MissingTransformers MissingONNX MissingSageAttention MissingInsightFace MissingOpenCV / cv2 Missing
Missing Packages

No module named 'torch' in ComfyUI

VerifiedHigh riskTested on Windows 10, Windows 11 | Launcher 1.x | ComfyUI portable

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

Tested Environment

  • OS: Windows 10 / 11
  • Launcher: Wonderful Launcher v1.x
  • ComfyUI: Portable / Managed install
  • Python: 3.11+
  • CUDA / Torch: CUDA 12.x / Torch 2.x
  • Last tested: 2026-05-19

If ComfyUI stops with ModuleNotFoundError: No module named 'torch', the Python environment that launched ComfyUI cannot import Torch at all.

This is a core runtime problem, not a cosmetic warning. In a real Windows portable repair, this appeared after comfy_aimdo was restored and before safetensors, which meant the environment had lost its base ML runtime packages.

Fast answer

For the GitHub Windows portable package, run these commands from the portable root:

.\python_embeded\python.exe -s -m pip show torch torchvision torchaudio
.\python_embeded\python.exe -s -m pip install torch
.\python_embeded\python.exe -s -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.is_available())"

If that last command prints a version ending in +cpu, or torch.version.cuda is None, you fixed the import but not the GPU build. Replace Torch with the matching CUDA wheel for your environment before relaunching ComfyUI.

What The Error Looked Like

In the tested portable repair lab, the blocking traceback looked like this:

ModuleNotFoundError: No module named 'torch'

After installing torch from the default index, the next verification printed:

2.12.0+cpu None False

That was an important trap. The import worked, but the environment had silently picked up a CPU-only Torch build.

Quick Diagnosis

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 output ends in +cpuYou repaired the import with a CPU-only wheelReplace it with a matching CUDA wheel
Next startup error becomes No module named 'torchvision' or No module named 'torchaudio'Torch is back, but adjacent core runtime packages are still missingRepair those next in the same environment
torch.cuda.is_available() is FalseGPU build mismatch, wrong wheel, or driver problemMove to the CUDA verification step below

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

For Windows portable:

.\python_embeded\python.exe -s -m pip install torch

For a manual venv:

python -m pip install torch

ComfyUI's current requirements.txt also expects torchvision and torchaudio, but if the first blocker is only torch, repair that first and restart. The next launch will tell you whether the neighboring packages are also missing.

Step 3: Verify You Did Not Accidentally 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')"

In the tested lab, the first pip install torch produced:

2.12.0+cpu None False

That was not good enough. The lab had to replace Torch from the PyTorch CUDA wheel index:

.\python_embeded\python.exe -s -m pip install `
  --index-url https://download.pytorch.org/whl/cu130 `
  --extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple `
  "torch==2.12.0+cu130"

After that, the same check returned:

2.12.0+cu130 13.0 True
NVIDIA GeForce RTX 4070 Ti SUPER

Use the wheel that matches your GPU, driver, Python version, and PyTorch support matrix. The tested cu130 command is evidence from one repaired environment, not a universal pin.

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

After Torch is restored, relaunch ComfyUI:

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

In the lab, the next blockers became:

  • ModuleNotFoundError: No module named 'safetensors'
  • then packaging
  • then numpy
  • later torchvision and torchaudio

That is normal in a damaged portable environment. Fix the next first blocker in the same Python instead of switching to random package commands.

If your environment keeps moving from one core package to another, use the broader 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 when you are still learning what broke
  • do not reinstall custom nodes until the core runtime is green again

How Wonderful Launcher Helps

This error is really an environment-boundary problem. Wonderful Launcher helps when you need to keep Python environments separate, preserve a known-good runtime, and compare startup logs after each package change.

If the same machine keeps drifting between CPU Torch and CUDA Torch, the real problem is usually unmanaged dependency changes, not only the missing torch import.

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

  • Windows portable repair lab, May 18, 2026: ModuleNotFoundError: No module named 'torch' appeared after comfy-aimdo was repaired
  • Same lab verification: default pip install torch produced 2.12.0+cpu None False
  • Same lab CUDA repair: replacing Torch with torch==2.12.0+cu130 restored GPU access on NVIDIA GeForce RTX 4070 Ti SUPER
  • PyTorch Start Locally installer

You can fix it manually, or download Wonderful Launcher for Windows to diagnose plugin errors, missing dependencies, and broken ComfyUI environments without reinstalling.

Download free for Windows

Did this fix your issue?

Your answer helps prioritize verified ComfyUI repairs.

ComfyUI Dependency Conflicts: Fix Without Reinstalling

Fix ComfyUI dependency conflicts after custom node installs, Torch downgrades, pip clashes, or broken plugin imports without destroying a working environment.

Transformers Missing

Fix ComfyUI No module named transformers errors in the active Python environment and understand when the failure comes from ComfyUI's core text stack.

Table of Contents

What The Error Looked Like
Quick Diagnosis
Step 1: Use The Python That Actually Starts ComfyUI
Step 2: Install Torch In The Active Environment
Step 3: Verify You Did Not Accidentally Install CPU Torch
Step 4: Restart And Read The Next First Error
What Not To Do
How Wonderful Launcher Helps
Related Guides
Source References