Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'xformers.ops' has no attribute 'AttentionOpDispatch' #1129

Closed
LarsDoorenbos opened this issue Oct 18, 2024 · 1 comment

Comments

@LarsDoorenbos
Copy link

LarsDoorenbos commented Oct 18, 2024

🐛 Bug

When trying to call xformers.ops.AttentionOpDispatch, an AttributeError is thrown.

Command

To Reproduce

Steps to reproduce the behavior:

  1. Create a Conda environment with Python 3.11
  2. Install PyTorch conda install pytorch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 -c pytorch
  3. Install xformers conda install xformers -c xformers
  4. Import xformers.ops and call xformers.ops.AttentionOpDispatch (as used in https://github.com/deeplearning-wisc/dream-ood/blob/main/ldm/modules/attention.py)
iPython 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xformers.ops
>>> xformers.ops.AttentionOpDispatch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'xformers.ops' has no attribute 'AttentionOpDispatch'

The same error happens when using the 0.0.13 version used in the repository I'm using (deeplearning-wisc/dream-ood#7), akin to deeplearning-wisc/dream-ood#18.

Expected behavior

The AttributeError is not thrown.

Environment

Collecting environment information...
PyTorch version: 2.4.1+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Rocky Linux 9.3 (Blue Onyx) (x86_64)
GCC version: (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2)
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.34

Python version: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.14.0-362.24.1.el9_3.0.1.x86_64-x86_64-with-glibc2.34
Is CUDA available: False
CUDA runtime version: 12.2.91
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      43 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             128
On-line CPU(s) list:                0-127
Vendor ID:                          AuthenticAMD
Model name:                         AMD EPYC 7742 64-Core Processor
CPU family:                         23
Model:                              49
Thread(s) per core:                 2
Core(s) per socket:                 64
Socket(s):                          1
Stepping:                           0
Frequency boost:                    enabled
CPU max MHz:                        2250.0000
CPU min MHz:                        1500.0000
BogoMIPS:                           4500.22
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sme sev sev_es
Virtualization:                     AMD-V
L1d cache:                          2 MiB (64 instances)
L1i cache:                          2 MiB (64 instances)
L2 cache:                           32 MiB (64 instances)
L3 cache:                           256 MiB (16 instances)
NUMA node(s):                       4
NUMA node0 CPU(s):                  0-15,64-79
NUMA node1 CPU(s):                  16-31,80-95
NUMA node2 CPU(s):                  32-47,96-111
NUMA node3 CPU(s):                  48-63,112-127
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; untrained return thunk; SMT enabled with STIBP protection
Vulnerability Spec rstack overflow: Mitigation; Safe RET
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines, IBPB conditional, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==2.0.1
[pip3] pytorch-ignite==0.5.0.post2
[pip3] pytorch-lightning==2.4.0
[pip3] torch==2.4.1
[pip3] torchaudio==2.3.0
[pip3] torchmetrics==1.4.3
[pip3] torchvision==0.19.1
[pip3] triton==3.0.0
[conda] blas                      1.0                         mkl
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46344
[conda] mkl-service               2.4.0           py311h5eee18b_1
[conda] mkl_fft                   1.3.10          py311h5eee18b_0
[conda] mkl_random                1.2.7           py311ha02d727_0
[conda] numpy                     2.0.1           py311h08b1b3b_1
[conda] numpy-base                2.0.1           py311hf175353_1
[conda] pytorch                   2.4.1           py3.11_cuda12.4_cudnn9.1.0_0    pytorch
[conda] pytorch-cuda              12.4                 hc786d27_7    pytorch
[conda] pytorch-lightning         2.4.0                    pypi_0    pypi
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                2.4.1               py311_cu124    pytorch
[conda] torchmetrics              1.4.3                    pypi_0    pypi
[conda] torchtriton               3.0.0                     py311    pytorch
[conda] torchvision               0.19.1              py311_cu124    pytorch

Additional context

The repo I'm copying does have a line of code stating NotImplementedError(f"Please install xformers with the flash attention / cutlass components.\n{err}"), perhaps that is what I am missing even though it throws an AttributeError instead of a NotImplementedError? How would I go about that?

Or, should I use a different attention.py file, such as e.g. described in AUTOMATIC1111/stable-diffusion-webui#576?

@LarsDoorenbos
Copy link
Author

Solved by replacing MemoryEfficientCrossAttention with the one in https://github.com/Stability-AI/stablediffusion/blob/main/ldm/modules/attention.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant