ComfyUI: ModuleNotFoundError: No module named 'onnxruntime' (fix)
ModuleNotFoundError: No module named 'onnxruntime' in ComfyUI usually comes from insightface, which InstantID and other face nodes import. We reproduced it on v0.37.0 with insightface 2.1 and fixed it.
1. The error
ComfyUI v0.37.0 (CPython 3.11, torch 2.9.0+cpu) with ComfyUI_InstantID in custom_nodes/, insightface 2.1 installed, and no ONNX Runtime in ComfyUI's Python:
[WARNING] Traceback (most recent call last):
File "venv/lib/python3.11/site-packages/insightface/__init__.py", line 14, in <module>
import onnxruntime
ModuleNotFoundError: No module named 'onnxruntime'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
...
File "ComfyUI/custom_nodes/ComfyUI_InstantID/__init__.py", line 1, in <module>
from .InstantID import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
File "ComfyUI/custom_nodes/ComfyUI_InstantID/InstantID.py", line 13, in <module>
from insightface.app import FaceAnalysis
File "venv/lib/python3.11/site-packages/insightface/__init__.py", line 18, in <module>
raise ImportError(
ImportError: InsightFace requires ONNX Runtime for inference, but the 'onnxruntime' module could not be imported. The default InsightFace installation includes `onnxruntime` for CPU/CoreML; restore it with `python -m pip install onnxruntime`. For NVIDIA CUDA, install `onnxruntime-gpu` only after uninstalling `onnxruntime`. Do not keep both runtime distributions in the same environment.
[INFO] 0.0 seconds (IMPORT FAILED): ComfyUI/custom_nodes/ComfyUI_InstantID
ComfyUI keeps running (exit code 0), but InstantID's nodes are missing. The first exception is the real one: insightface/__init__.py line 14 does import onnxruntime, and insightface 2.1 wraps the failure in its own ImportError with the fix in the message. Any other node pack that imports insightface fails the same way.
2. Fix: install ONNX Runtime into ComfyUI's Python
python -m pip install onnxruntime
That installed onnxruntime 1.31.0 and after a restart:
[INFO] 0.2 seconds: ComfyUI/custom_nodes/ComfyUI_InstantID
For NVIDIA GPU inference use onnxruntime-gpu instead. insightface's message says to install it only after uninstalling onnxruntime and not to keep both in one environment. Note that InstantID's requirements.txt lists onnxruntime and also onnxruntime-gpu (on x86_64, non-macOS), so pip install -r requirements.txt installs both; check with python -m pip list | grep onnxruntime (Windows: findstr instead of grep).
Use the Python that runs main.py: activate the venv first, or on the Windows portable build run python_embeded\python.exe -m pip install onnxruntime from the ComfyUI_windows_portable folder.
Related: ComfyUI: No module named 'insightface' · ComfyUI: No module named 'cv2' · ComfyUI: No module named 'yaml' (wrong Python)
Frequently asked questions
onnxruntime or onnxruntime-gpu?
onnxruntime for CPU (and CoreML on Mac); onnxruntime-gpu for NVIDIA CUDA. insightface 2.1 says to keep only one of them installed.
Does ComfyUI stop when onnxruntime is missing?
No. ComfyUI starts; only the node pack that imports insightface is marked IMPORT FAILED.
Written with AI assistance. Measured on 2026-10-24 on Linux, CPython 3.11.17: ComfyUI v0.37.0, torch 2.9.0+cpu, ComfyUI_InstantID at commit 72495e8, insightface 2.1, without and with onnxruntime 1.31.0. Output pasted unedited except shortened paths and a trimmed traceback. PlainTables is our extension; ComfyUI, InstantID, insightface and ONNX Runtime are free.