Segmentation fault (core dumped) in torch 2.1.0

MartinKim: <p>Hello<br>
I’m encountering a problem while running a mamba-asr model. The script crashes with the message ‘Segmentation fault (core dumpted)’ after a few steps. This error seems to occur ramdomly. Additionally, another error occurs during training, namely an error like “runtimeError: d.is_cuda() INTERNAL ASSERT FAILED at “…/c10/cuda/impl/CUDAGuardImpl.h”:31, please report a bug to PyTorch.”</p>
<p>Here are my settings:<br>
Ubuntu 22.04<br>
Cuda 12.1<br>
GPU : A6000 x2 49GB<br>
PyTorch 2.1.0</p>
<p>Is there any solution to solve this problem?</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/2/12a19d501e6ae32c82a1c1d8aaf17b23864fc511.png" data-download-href="https://discuss.pytorch.org/uploads/default/12a19d501e6ae32c82a1c1d8aaf17b23864fc511" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/2/12a19d501e6ae32c82a1c1d8aaf17b23864fc511.png" alt="image" data-base62-sha1="2EOQOSsEUZ5nHyW2yAEc1QoxoTD" width="690" height="138" data-dominant-color="4E4E4E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1670×336 15.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>Do you see these issues in the latest stable or nightly releases?</p>

MartinKim: <p>No, I haven’t tried it yet. However, when I run this code in a single GPU (NVIDIA RTX 4060) environment, no errors occurred at all. Could this be caused by incorrect connection when connecting two A6000s?</p>

AFDtea: <p>I have encountered this same issue as well.</p>
<p>Ubuntu 24.04<br>
Cuda 12.4<br>
GPU : RTX 4090 24GB<br>
PyTorch 2.7.1</p>
<p>I had been running this same training script for weeks when the exact same crashing and seg faulting started to occur and after reinstalling drivers and monitoring the GPU I cannot seem to diagnose the issue.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/e/9e25104d950f012fc5a35ed3239393a05f6d761c.png" data-download-href="https://discuss.pytorch.org/uploads/default/9e25104d950f012fc5a35ed3239393a05f6d761c" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/9/e/9e25104d950f012fc5a35ed3239393a05f6d761c.png" alt="image" data-base62-sha1="mz0QDcnjC7gTBYZK4ERAJlVmkSU" width="690" height="372" data-dominant-color="F1F0F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1599×863 48.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

Bugnetic: <p>I have the same issue.</p>
<p>Environment:<br>
PyTorch version: 2.5.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 24.04.2 LTS (x86_64)<br>
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0<br>
Clang version: Could not collect<br>
CMake version: Could not collect<br>
Libc version: glibc-2.39</p>
<p>Python version: 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0] (64-bit runtime)<br>
Python platform: Linux-6.8.0-63-generic-x86_64-with-glibc2.39<br>
Is CUDA available: True<br>
CUDA runtime version: Could not collect<br>
CUDA_MODULE_LOADING set to: LAZY<br>
GPU models and configuration:<br>
GPU 0: NVIDIA GeForce RTX 4090<br>
GPU 1: NVIDIA GeForce RTX 4090</p>
<p>Nvidia driver version: 535.247.01<br>
cuDNN version: Could not collect<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:                        39 bits physical, 48 bits virtual<br>
Byte Order:                           Little Endian<br>
CPU(s):                               24<br>
On-line CPU(s) list:                  0-23<br>
Vendor ID:                            GenuineIntel<br>
Model name:                           Intel(R) Core™ i9-14900KF<br>
CPU family:                           6<br>
Model:                                183<br>
Thread(s) per core:                   1<br>
Core(s) per socket:                   24<br>
Socket(s):                            1<br>
Stepping:                             1<br>
CPU(s) scaling MHz:                   85%<br>
CPU max MHz:                          6000.0000<br>
CPU min MHz:                          800.0000<br>
BogoMIPS:                             6374.40<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 tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities<br>
Virtualization:                       VT-x<br>
L1d cache:                            896 KiB (24 instances)<br>
L1i cache:                            1.3 MiB (24 instances)<br>
L2 cache:                             32 MiB (12 instances)<br>
L3 cache:                             36 MiB (1 instance)<br>
NUMA node(s):                         1<br>
NUMA node0 CPU(s):                    0-23<br>
Vulnerability Gather data sampling:   Not affected<br>
Vulnerability Itlb multihit:          Not affected<br>
Vulnerability L1tf:                   Not affected<br>
Vulnerability Mds:                    Not affected<br>
Vulnerability Meltdown:               Not affected<br>
Vulnerability Mmio stale data:        Not affected<br>
Vulnerability Reg file data sampling: Mitigation; Clear Register File<br>
Vulnerability Retbleed:               Not affected<br>
Vulnerability Spec rstack overflow:   Not affected<br>
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl<br>
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization<br>
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S<br>
Vulnerability Srbds:                  Not affected<br>
Vulnerability Tsx async abort:        Not affected</p>
<p>Versions of relevant libraries:<br>
[pip3] flake8==7.0.0<br>
[pip3] numpy==1.26.4<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.21.5<br>
[pip3] nvidia-nvjitlink-cu12==12.1.105<br>
[pip3] nvidia-nvtx-cu12==12.1.105<br>
[pip3] torch==2.5.1+cu121<br>
[pip3] torchaudio==2.5.1+cu121<br>
[pip3] torchvision==0.20.1+cu121<br>
[pip3] triton==3.1.0<br>
[pip3] types-flake8-2020==1.8<br>
[pip3] types-flake8-bugbear==23.9.16<br>
[pip3] types-flake8-builtins==2.2<br>
[pip3] types-flake8-docstrings==1.7<br>
[pip3] types-flake8-plugin-utils==1.3<br>
[pip3] types-flake8-rst-docstrings==0.3<br>
[pip3] types-flake8-simplify==0.21<br>
[pip3] types-flake8-typing-imports==1.15<br>
[pip3] types-mypy-extensions==1.0<br>
[conda] Could not collectPyTorch version: 2.7.1+cu126<br>
Is debug build: False<br>
CUDA used to build PyTorch: 12.6<br>
ROCM used to build PyTorch: N/A</p>
<p>OS: Ubuntu 24.04.2 LTS (x86_64)<br>
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0<br>
Clang version: Could not collect<br>
CMake version: Could not collect<br>
Libc version: glibc-2.39</p>
<p>Python version: 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0] (64-bit runtime)<br>
Python platform: Linux-6.8.0-63-generic-x86_64-with-glibc2.39<br>
Is CUDA available: True<br>
CUDA runtime version: Could not collect<br>
CUDA_MODULE_LOADING set to: LAZY<br>
GPU models and configuration:<br>
GPU 0: NVIDIA GeForce RTX 4090<br>
GPU 1: NVIDIA GeForce RTX 4090</p>
<p>Nvidia driver version: 535.247.01<br>
cuDNN version: Could not collect<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:                        39 bits physical, 48 bits virtual<br>
Byte Order:                           Little Endian<br>
CPU(s):                               24<br>
On-line CPU(s) list:                  0-23<br>
Vendor ID:                            GenuineIntel<br>
Model name:                           Intel(R) Core™ i9-14900KF<br>
CPU family:                           6<br>
Model:                                183<br>
Thread(s) per core:                   1<br>
Core(s) per socket:                   24<br>
Socket(s):                            1<br>
Stepping:                             1<br>
CPU(s) scaling MHz:                   70%<br>
CPU max MHz:                          6000.0000<br>
CPU min MHz:                          800.0000<br>
BogoMIPS:                             6374.40<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 tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities<br>
Virtualization:                       VT-x<br>
L1d cache:                            896 KiB (24 instances)<br>
L1i cache:                            1.3 MiB (24 instances)<br>
L2 cache:                             32 MiB (12 instances)<br>
L3 cache:                             36 MiB (1 instance)<br>
NUMA node(s):                         1<br>
NUMA node0 CPU(s):                    0-23<br>
Vulnerability Gather data sampling:   Not affected<br>
Vulnerability Itlb multihit:          Not affected<br>
Vulnerability L1tf:                   Not affected<br>
Vulnerability Mds:                    Not affected<br>
Vulnerability Meltdown:               Not affected<br>
Vulnerability Mmio stale data:        Not affected<br>
Vulnerability Reg file data sampling: Mitigation; Clear Register File<br>
Vulnerability Retbleed:               Not affected<br>
Vulnerability Spec rstack overflow:   Not affected<br>
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl<br>
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization<br>
Vulnerability Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S<br>
Vulnerability Srbds:                  Not affected<br>
Vulnerability Tsx async abort:        Not affected</p>
<p>Versions of relevant libraries:<br>
[pip3] numpy==2.3.1<br>
[pip3] nvidia-cublas-cu12==12.6.4.1<br>
[pip3] nvidia-cuda-cupti-cu12==12.6.80<br>
[pip3] nvidia-cuda-nvrtc-cu12==12.6.77<br>
[pip3] nvidia-cuda-runtime-cu12==12.6.77<br>
[pip3] nvidia-cudnn-cu12==9.5.1.17<br>
[pip3] nvidia-cufft-cu12==11.3.0.4<br>
[pip3] nvidia-curand-cu12==10.3.7.77<br>
[pip3] nvidia-cusolver-cu12==11.7.1.2<br>
[pip3] nvidia-cusparse-cu12==12.5.4.2<br>
[pip3] nvidia-cusparselt-cu12==0.6.3<br>
[pip3] nvidia-nccl-cu12==2.26.2<br>
[pip3] nvidia-nvjitlink-cu12==12.6.85<br>
[pip3] nvidia-nvtx-cu12==12.6.77<br>
[pip3] torch==2.7.1<br>
[pip3] torcheval==0.0.7<br>
[pip3] torchvision==0.22.1<br>
[pip3] triton==3.3.1<br>
[conda] Could not collect</p>
<p>Actually, after several trials, I suspect the problem is due to a failure in synchronization due to the Triton generated kernels. My guess comes from a bunch of errors raised other than the usual “segmentation fault (core dumped)” one.<br>
I’m providing you with a some of these error essential lines and my (possibly wrong) explanation in the hope that they can be of help.</p>
<pre><code class="lang-auto">...
E0620 15:26:01.373000 75212 torch/_inductor/runtime/triton_heuristics.py:539
RuntimeError: PassManager::run failed
Segmentation fault (core dumped)
</code></pre>
<p>This is a Triton (Inductor kernel) compilation crash during a fused <code>group_norm + backward</code> operation.</p>
<pre><code class="lang-auto">free(): corrupted unsorted chunks
malloc(): unsorted double linked list corrupted
gcc: internal compiler error: Aborted signal terminated program cc1
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See &lt;file:///usr/share/doc/gcc-13/README.Bugs&gt; for instructions.
...
torch._inductor.exc.InductorError: CalledProcessError: Command '['/usr/bin/gcc', '/tmp/tmpogrgxzqp/main.c', '-O3', '-shared', '-fPIC', '-Wno-psabi', '-o', '/tmp/tmpogrgxzqp/__triton_launcher.cpython-312-x86_64-linux-gnu.so', '-lcuda', '-L/home/poire/fresh_env/lib/python3.12/site-packages/triton/backends/nvidia/lib', '-L/lib/x86_64-linux-gnu', '-I/home/poire/fresh_env/lib/python3.12/site-packages/triton/backends/nvidia/include', '-I/tmp/tmpogrgxzqp', '-I/usr/include/python3.12']' returned non-zero exit status 4.
</code></pre>
<p>This error looks to show a failure inside the compiler itself—GCC detected heap corruption while trying to compile Triton-generated kernels and aborted.</p>
<pre><code class="lang-auto">warnings.warn(
exception calling callback for &lt;Future at 0x75df909c3a70 state=finished returned bytes&gt;
Traceback (most recent call last):
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 340, in _invoke_callbacks
    callback(self)
  File "/home/poire/fresh_env/lib/python3.12/site-packages/torch/_inductor/compile_worker/subproc_pool.py", line 326, in callback
    _send_msg(self.write_pipe, job_id, result)
  File "/home/poire/fresh_env/lib/python3.12/site-packages/torch/_inductor/compile_worker/subproc_pool.py", line 50, in _send_msg
    write_pipe.write(job_data)
BrokenPipeError: [Errno 32] Broken pipe
Segmentation fault (core dumped)
</code></pre>
<p>Here, it looks like the failure is coming from the Inductor’s asynchronous compile workers crashing mid-flight—when a worker process segfaults, its parent tries to write back the compiled kernel bytes over a pipe and finds the other end gone, hence the <code>BrokenPipeError</code>.</p>
<p>I don’t know if there can be any relationship because of the fx graph generation, but I get the same “segmentation fault (core dumped)” error when performing quantization using Pytorch 2 Export Quantization mode. The following is the error I got when assessing the accuracy of the quantized model:</p>
<pre><code class="lang-auto">RuntimeError: CUDA error: misaligned address
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.
</code></pre>
<p>A workaround I am applying to reduce the error raising is to use <code>print()</code> functions and setting the <code>drop_last</code> dataloader argument to <code>True</code>. This, in theory, should do the same thing under the hood:<br>
1- <code>print()</code> functions force synchronization between Triton’s asynchronous kernel compile &amp; your model’s execution,<br>
2- <code>drop_last</code> eliminates the dynamic‐shape edge case of a smaller “last” batch (which would trigger a second, differently‑shaped specialization).</p>

AFDtea: <p>My specific problem: d.is_cuda() INTERNAL ASSERT FAILED at “pytorch/c10/impl/CUDAGuardImpl.h”:34 was fixed by both updating my BIOS and deactivating hyperthreading. Probably something to do with Ubuntu but I am not positive.</p>