Torch.cuda.max_memory_allocated() raise torch._dynamo.exc.BackendCompilerFailed

username: JuyiLin
cooked: <h1><a name="p-457634-torchcudamax_memory_allocated-raise-torch_dynamoexcbackendcompilerfailed-backendinductor-raised-indexerror-mapat-138372-1" class="anchor" href="#p-457634-torchcudamax_memory_allocated-raise-torch_dynamoexcbackendcompilerfailed-backendinductor-raised-indexerror-mapat-138372-1"></a>torch.cuda.max_memory_allocated() raise torch._dynamo.exc.BackendCompilerFailed: backend=‘inductor’ raised: IndexError: map::at <span class="hashtag-raw">#138372</span></h1>
<p>torch.cuda.max_memory_allocated（） raise torch._dynamo.exc.BackendCompilerFailed： backend=‘inductor’ raised： IndexError：<br>
map：：at</p>
<p>I am trying to reporduce <a href="https://pytorch.org/blog/accelerating-generative-ai-3/" class="inline-onebox" rel="noopener nofollow ugc">Accelerating Generative AI Part III: Diffusion, Fast | PyTorch</a></p>
<pre><code class="lang-auto">from diffusers import AutoPipelineForText2Image
import torch
import matplotlib.pyplot as plt
import time

torch.cuda.empty_cache()
torch.cuda.reset_peak_memory_stats()

pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
pipe.to("cuda")

prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe."
guidance_scale = 7.5  # Set the guidance scale to your desired value

pipe.unet = torch.compile(pipe.unet, mode="max-autotune", fullgraph=True)
pipe.vae.decode = torch.compile(pipe.vae.decode, mode="max-autotune", fullgraph=True)

start_time = time.time()
image = pipe(prompt=prompt, num_inference_steps=30, guidance_scale=guidance_scale).images[0]
end_time = time.time()
elapsed_time = end_time - start_time
gpu_memory_used = torch.cuda.max_memory_allocated() / 1024**3  # Convert to GB
</code></pre>
<p>It shows</p>
<pre><code class="lang-auto">E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433] Traceback (most recent call last):
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]   File "/usr/local/lib/python3.10/dist-packages/torch/_inductor/runtime/triton_heuristics.py", line 431, in _precompile_config
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]     binary = triton.compile(*compile_args, **compile_kwargs)
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]   File "/usr/local/lib/python3.10/dist-packages/triton/compiler/compiler.py", line 282, in compile
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]     next_module = compile_ir(module, metadata)
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]   File "/usr/local/lib/python3.10/dist-packages/triton/backends/nvidia/compiler.py", line 318, in &lt;lambda&gt;
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]     stages["llir"] = lambda src, metadata: self.make_llir(src, metadata, options, self.capability)
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]   File "/usr/local/lib/python3.10/dist-packages/triton/backends/nvidia/compiler.py", line 216, in make_llir
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433]     pm.run(mod)
E1018 22:16:22.154000 140417966265920 torch/_inductor/runtime/triton_heuristics.py:433] IndexError: map::at
</code></pre>
<h3><a name="p-457634-versions-2" class="anchor" href="#p-457634-versions-2"></a>Versions</h3>
<p>PyTorch version: 2.4.1+cu121<br>
Is debug build: False<br>
CUDA used to build PyTorch: 12.1<br>
ROCM used to build PyTorch: N/A</p>
<p>OS: Ubuntu 22.04.2 LTS (x86_64)<br>
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0<br>
Clang version: Could not collect<br>
CMake version: version 3.27.1<br>
Libc version: glibc-2.35</p>
<p>Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (64-bit runtime)<br>
Python platform: Linux-4.15.0-213-generic-x86_64-with-glibc2.35<br>
Is CUDA available: True<br>
CUDA runtime version: 12.2.128<br>
CUDA_MODULE_LOADING set to: LAZY<br>
GPU models and configuration:<br>
GPU 0: NVIDIA GeForce RTX 2080 Ti<br>
GPU 1: NVIDIA GeForce RTX 2080 Ti<br>
GPU 2: NVIDIA GeForce RTX 2080 Ti<br>
GPU 3: NVIDIA GeForce RTX 2080 Ti<br>
GPU 4: NVIDIA GeForce RTX 2080 Ti<br>
GPU 5: NVIDIA GeForce RTX 2080 Ti<br>
GPU 6: NVIDIA GeForce RTX 2080 Ti<br>
GPU 7: NVIDIA GeForce RTX 2080 Ti</p>
<p>Nvidia driver version: 535.113.01<br>
cuDNN version: Probably one of the following:<br>
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.4<br>
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.4<br>
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.4<br>
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.4<br>
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.4<br>
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.4<br>
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.4<br>
HIP runtime version: N/A<br>
MIOpen runtime version: N/A<br>
Is XNNPACK available: True</p>
<p>CPU:<br>
Architecture: x86_64<br>
CPU op-mode(s): 32-bit, 64-bit<br>
Address sizes: 46 bits physical, 48 bits virtual<br>
Byte Order: Little Endian<br>
CPU(s): 64<br>
On-line CPU(s) list: 0-63<br>
Vendor ID: GenuineIntel<br>
Model name: Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz<br>
CPU family: 6<br>
Model: 85<br>
Thread(s) per core: 2<br>
Core(s) per socket: 16<br>
Socket(s): 2<br>
Stepping: 7<br>
Frequency boost: enabled<br>
CPU max MHz: 2301.0000<br>
CPU min MHz: 1000.0000<br>
BogoMIPS: 4600.00<br>
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities<br>
Virtualization: VT-x<br>
L1d cache: 1 MiB (32 instances)<br>
L1i cache: 1 MiB (32 instances)<br>
L2 cache: 32 MiB (32 instances)<br>
L3 cache: 44 MiB (2 instances)<br>
NUMA node(s): 2<br>
NUMA node0 CPU(s): 0-15,32-47<br>
NUMA node1 CPU(s): 16-31,48-63<br>
Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages<br>
Vulnerability L1tf: Not affected<br>
Vulnerability Mds: Not affected<br>
Vulnerability Meltdown: Not affected<br>
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable<br>
Vulnerability Retbleed: Mitigation; Enhanced IBRS<br>
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp<br>
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization<br>
Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence<br>
Vulnerability Srbds: Not affected<br>
Vulnerability Tsx async abort: Mitigation; TSX disabled</p>
<p>Versions of relevant libraries:<br>
[pip3] numpy==1.22.2<br>
[pip3] nvidia-cublas-cu12==12.1.3.1<br>
[pip3] nvidia-cuda-cupti-cu12==12.1.105<br>
[pip3] nvidia-cuda-nvrtc-cu12==12.1.105<br>
[pip3] nvidia-cuda-runtime-cu12==12.1.105<br>
[pip3] nvidia-cudnn-cu12==9.1.0.70<br>
[pip3] nvidia-cufft-cu12==11.0.2.54<br>
[pip3] nvidia-curand-cu12==10.3.2.106<br>
[pip3] nvidia-cusolver-cu12==11.4.5.107<br>
[pip3] nvidia-cusparse-cu12==12.1.0.106<br>
[pip3] nvidia-nccl-cu12==2.20.5<br>
[pip3] nvidia-nvjitlink-cu12==12.6.77<br>
[pip3] nvidia-nvtx-cu12==12.1.105<br>
[pip3] nvtx==0.2.5<br>
[pip3] onnx==1.14.0<br>
[pip3] pytorch-quantization==2.1.2<br>
[pip3] torch==2.4.1<br>
[pip3] torch-tensorrt==2.0.0.dev0<br>
[pip3] torchao==0.5.0<br>
[pip3] torchdata==0.7.0a0<br>
[pip3] torchtext==0.16.0a0<br>
[pip3] torchvision==0.19.1<br>
[pip3] triton==3.0.0<br>
[conda] Could not collect</p>

username: ptrblck
cooked: <p>Do you see the same error in the recently released <code>torch==2.5.0</code> binary or a nightly binary?</p>