ComfyUI-MultiGPU icon indicating copy to clipboard operation
ComfyUI-MultiGPU copied to clipboard

p2p_registry.py hardcodes libcudart.so - always crashes on Windows (fix included)

Open Enigmatic331 opened this issue 3 months ago • 1 comments

Hit this on windows while trying to run the new MiniMax H3 models with device pinning.

p2p_registry.py does this:

def _get_libcudart():
    """Load libcudart.so once and cache the handle."""
    global _libcudart
    if _libcudart is None:
        _libcudart = ctypes.CDLL("libcudart.so")
    return _libcudart

libcudart.so doesn't exist on windows... so the first time the P2P check runs, the whole generation dies with:

FileNotFoundError: Could not find module 'libcudart.so' (or one of its dependencies). Try using the full path with constructor syntax.

On windows the runtime ships inside torch as torch\lib\cudart64_*.dll (mine is cudart64_13.dll on torch 2.13.0+cu130). This is what I'm running locally and it works:

def _get_libcudart():
    """Load the CUDA runtime library once and cache the handle."""
    global _libcudart
    if _libcudart is None:
        import os
        import sys
        if sys.platform == "win32":
            # Windows: cudart64_*.dll ships inside torch/lib
            torch_lib = os.path.join(os.path.dirname(torch.__file__), "lib")
            candidates = sorted(
                f for f in os.listdir(torch_lib)
                if f.startswith("cudart64_") and f.endswith(".dll")
            )
            if not candidates:
                raise FileNotFoundError(f"No cudart64_*.dll found in {torch_lib}")
            _libcudart = ctypes.CDLL(os.path.join(torch_lib, candidates[-1]))
        else:
            _libcudart = ctypes.CDLL("libcudart.so")
    return _libcudart

happy to PR this if you want.

Env: Windows 11 Pro / ComfyUI 0.30.0 (14b0522) / ComfyUI-MultiGPU b51c99a / Python 3.12.10 / torch 2.13.0+cu130 / 2x RTX 5090 + RTX 4080 Super

Repro: any workflow that reaches the P2P accessibility check on windows - I hit it via MiniMax H3 with UNETLoaderMultiGPU/CLIPLoaderMultiGPU pinning models to different cards.

Enigmatic331 avatar Aug 04 '26 19:08 Enigmatic331

This code crashed my comfyui making it cannot launch.

truss-frame avatar Sep 24 '26 16:09 truss-frame