OpenCV setNumThreads_0
The global cap on OpenCV's CPU threads
- unknown
setNumThreads_0 caps how many threads OpenCV uses for its own CPU-side parallel work. One input, no usable output, one global side effect. It's cv2.setNumThreads wrapped, and it's about as unglamorous as nodes get.
Why it exists: OpenCV's image processing is heavily parallelized on the CPU, and on big machines it will happily spawn a thread per core. Usually that's exactly what you want - your Gaussian blur finishes faster. But there are real situations where you want it capped. You're running ComfyUI on a shared box where other things need CPU. You're on a laptop where OpenCV hogging every core thrashes the machine. Or you're debugging a race condition and want to see if parallel execution is the culprit. In those cases, set a number and the rest of OpenCV obeys.
The inputs and outputs are stark:
- nthreads - INT. The number of threads OpenCV may use.
0means "let OpenCV decide" (it auto-detects the hardware), which is the safe default. Any positive number is an explicit cap. - The output is literally
None- the schema names itunknown, and that's the auto-generator's way of saying the function returns nothing. There is nothing to wire. This is a fire-and-forget node.
Two honest caveats. First, it only affects OpenCV's own thread pool. Numpy, torch, and anything else in your graph do their own thing, so this isn't a global "limit all CPU usage" switch. Second, and this is the one that trips people up: it's a global setting that persists for the rest of the ComfyUI process. If you set it to 1 in one workflow and then load another, the cap is still there. ComfyUI's execution order isn't tied to graph layout either, so a "set to 8" node sitting visually before a "set to 1" node doesn't guarantee that order. If you ever touch this node, set it once with a fixed value and don't get clever.
Installation is the pack's one-liner: ComfyUI Manager → search "opencv-comfyui", or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. It needs opencv-contrib-python on top of the numpy/torch ComfyUI already ships. Watch for the known conflict: Cannot import name 'guidedFilter' from 'cv2.ximgproc' at startup means another node installed a second OpenCV build - uninstall the duplicate.
My take: 99% of ComfyUI users should never run this node. The heavy lifting is on your GPU, and OpenCV's default thread count is usually right. It earns its place on the rare workstation that's being squeezed for CPU while a workflow runs - and as a debugging tool when you suspect parallel races. Beyond that, it's a curiosity the auto-generator produced because the pack faithfully wraps every standalone cv2 function.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| nthreads | INT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| unknown | None | — |