kijai/ComfyUI-MochiWrapper

ModuleNotFoundError: No module named 'torch.nn.attention’

Closed this issue · 2 comments

Traceback (most recent call last):
File "/root/ComfyUI/nodes.py", line 2006, in load_custom_node
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/root/ComfyUI/custom_nodes/ComfyUI-MochiWrapper/init.py", line 1, in
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
File "/root/ComfyUI/custom_nodes/ComfyUI-MochiWrapper/nodes.py", line 15, in
from .mochi_preview.t2v_synth_mochi import T2VSynthMochiModel
File "/root/ComfyUI/custom_nodes/ComfyUI-MochiWrapper/mochi_preview/t2v_synth_mochi.py", line 54, in
from .dit.joint_model.asymm_models_joint import AsymmDiTJoint
File "/root/ComfyUI/custom_nodes/ComfyUI-MochiWrapper/mochi_preview/dit/joint_model/asymm_models_joint.py", line 40, in
from torch.nn.attention import sdpa_kernel, SDPBackend
ModuleNotFoundError: No module named 'torch.nn.attention'

Name: torch
Version: 2.5.0+cu124
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages@pytorch.org
License: BSD-3-Clause
Location: /root/miniconda3/lib/python3.10/site-packages
Requires: filelock, fsspec, jinja2, networkx, nvidia-cublas-cu12, nvidia-cuda-cupti-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-runtime-cu12, nvidia-cudnn-cu12, nvidia-cufft-cu12, nvidia-curand-cu12, nvidia-cusolver-cu12, nvidia-cusparse-cu12, nvidia-nccl-cu12, nvidia-nvjitlink-cu12, nvidia-nvtx-cu12, sympy, triton, typing-extensions
Required-by: accelerate, torchaudio, torchvision, xformers

torch version 2.5.0, why still can't find the module

If you are getting that error, the actual torch in the python environment you are running ComfyUI can not be 2.5.0

dw

On torch 2.5.1 and still missing nodes.

"Cannot import C:\Users\dani\SD\COMFYUI\ComfyUI\custom_nodes\ComfyUI-MochiWrapper module for custom nodes: No module named 'torch.nn.attention'"

My Comfyui torch is - pytorch version: 2.1.2+cu121. Not sure how to change it.

EDIT: Fixed with - run this command in the python_embeded folder:

python.exe -s -m pip install --upgrade torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 -r ../ComfyUI/requirements.txt pygit2