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

Segmentation fault in torch.stft, cufftXtMakePlanMany #111764

Closed
albertz opened this issue Oct 22, 2023 · 3 comments
Closed

Segmentation fault in torch.stft, cufftXtMakePlanMany #111764

albertz opened this issue Oct 22, 2023 · 3 comments

Comments

@albertz
Copy link
Contributor

albertz commented Oct 22, 2023

🐛 Describe the bug

I have not created a reproducing simple test case yet. This was in a larger project, and the same code also has run fine before, so maybe it's not really a PyTorch bug but I messed sth up with my environment. But a quick search did not reveal any similar crashes, so that's why I'm reporting it here.

In this training run, epoch 151 was loaded from an earlier checkpoint, so this happened very early after startup.

It seems quite deterministic. After I run it again in GDB, I got the crash exactly in the same step.

Log:

...
ep 151 train, step 151, ce 1.088, ctc_4 1.368, ctc_8 1.175, fer 0.234                                                   
ep 151 train, step 152, ce 1.359, ctc_4 1.829, ctc_8 1.635, fer 0.256                                                   
ep 151 train, step 153, ce 1.193, ctc_4 1.786, ctc_8 1.466, fer 0.242                                                   
ep 151 train, step 154, ce 1.120, ctc_4 1.587, ctc_8 1.355, fer 0.232                                                   
ep 151 train, step 155, ce 1.162, ctc_4 1.554, ctc_8 1.305, fer 0.220                                                   
ep 151 train, step 156, ce 1.398, ctc_4 1.901, ctc_8 1.710, fer 0.273                                                   
                                                                                                                        
Thread 1 "python3.10" received signal SIGSEGV, Segmentation fault.                                                      
0x00007fffbb1cb2f2 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1                                                 
(gdb) bt                                                                                                                
#0  0x00007fffbb1cb2f2 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1                                             
#1  0x00007fffdb0b935c in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10                    
#2  0x00007fffdae1b14f in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10                    
#3  0x00007fffdae43b75 in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10     
#4  0x00007fffdae468a7 in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10                    
#5  0x00007fffdae3344c in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10                    
#6  0x00007fffdae3519b in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10                    
#7  0x00007fffdae35ca4 in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10                    
#8  0x00007fffdae3ec25 in ?? ()                                                                                         
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#9  0x00007fffdae3f1e0 in ?? ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#10 0x00007fffdae7c6dd in ?? ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#11 0x00007fffdae7d38c in ?? ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#12 0x00007fffdae72196 in ?? ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#13 0x00007fffdae26d35 in ?? ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#14 0x00007fffdae6e855 in cufftXtMakePlanMany ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/../../nvidia/cufft/lib/libcufft.so.10
#15 0x00007fff7bd037b4 in at::native::detail::CuFFTConfig::CuFFTConfig(c10::ArrayRef<long>, c10::ArrayRef<long>, c10::ArrayRef<long>, at::native::detail::CuFFTTransformType, c10::ScalarType) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
#16 0x00007fff7bcfc69f in at::native::(anonymous namespace)::_exec_fft(at::Tensor&, at::Tensor const&, c10::ArrayRef<long>, c10::ArrayRef<long>, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
#17 0x00007fff7bcfd45e in at::native::_fft_r2c_cufft(at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
#18 0x00007fff7d9fbe74 in at::(anonymous namespace)::(anonymous namespace)::wrapper_CUDA___fft_r2c(at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
#19 0x00007fff7d9fbefe in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (at::Tensor const&, c10::ArrayRef<long>, long, bool), &at::(anonymous namespace)::(anonymous namespace)::wrapper_CUDA___fft_r2c>, at::Tensor, c10::guts::typelist::typelist<at::Tensor const&, c10::ArrayRef<long>, long, bool> >, at::Tensor (at::Tensor const&, c10::ArrayRef<long>, long, bool)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
#20 0x00007fffa383195e in at::_ops::_fft_r2c::redispatch(c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so
#21 0x00007fffa512bb75 in torch::autograd::VariableType::(anonymous namespace)::_fft_r2c(c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so
#22 0x00007fffa512c245 in c10::impl::wrap_kernel_functor_unboxed_<c10::impl::detail::WrapFunctionIntoFunctor_<c10::CompileTimeFunctionPointer<at::Tensor (c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool), &torch::autograd::VariableType::(anonymous namespace)::_fft_r2c>, at::Tensor, c10::guts::typelist::typelist<c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool> >, at::Tensor (c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool)>::call(c10::OperatorKernel*, c10::DispatchKeySet, at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so
--Type <RET> for more, q to quit, c to continue without paging--
#23 0x00007fffa387b1e9 in at::_ops::_fft_r2c::call(at::Tensor const&, c10::ArrayRef<long>, long, bool) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so
#24 0x00007fffa2e937c1 in at::native::stft(at::Tensor const&, long, c10::optional<long>, c10::optional<long>, c10::optional<at::Tensor> const&, bool, c10::basic_string_view<char>, bool, c10::optional<bool>, c10::optional<bool>) ()
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_cpu.so
...
#30 0x00007fffba39d9e2 in torch::autograd::THPVariable_stft(_object*, _object*, _object*) ()                               
   from /u/zeyer/.local/lib/python3.10/site-packages/torch/lib/libtorch_python.so                                       
...

Versions

The collect_env script failed for some reason:

Collecting environment information...
Traceback (most recent call last):
  File "/u/zeyer/pytorch-collect-env.py", line 612, in <module>
    main()
  File "/u/zeyer/pytorch-collect-env.py", line 595, in main
    output = get_pretty_env_info()
  File "/u/zeyer/pytorch-collect-env.py", line 590, in get_pretty_env_info
    return pretty_str(get_env_info())
  File "/u/zeyer/pytorch-collect-env.py", line 428, in get_env_info
    pip_version, pip_list_output = get_pip_packages(run_lambda)
  File "/u/zeyer/pytorch-collect-env.py", line 400, in get_pip_packages
    out = run_with_pip([sys.executable, '-mpip'])
  File "/u/zeyer/pytorch-collect-env.py", line 384, in run_with_pip
    for line in out.splitlines()
AttributeError: 'NoneType' object has no attribute 'splitlines'

Anyway, some manually collected info:

  • PyTorch 2.0.1+cu117
  • Ubuntu Linux 22.04
  • NVIDIA GeForce GTX 1080 Ti

Edit Ok, it seems PIP was somehow broken in this environment. After fixing this, I get this output from the script:

Collecting environment information...                                                                                   
PyTorch version: 2.0.1+cu117                                
Is debug build: False                                       
CUDA used to build PyTorch: 11.7                       
ROCM used to build PyTorch: N/A                      
                                                            
OS: Ubuntu 22.04.2 LTS (x86_64)   
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 15.0.7                                       
CMake version: version 3.26.3                                                                                           
Libc version: glibc-2.35                                                                                                
                                                                                                                        
Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-39-generic-x86_64-with-glibc2.35                
Is CUDA available: True                                                                                                 
CUDA runtime version: Could not collect                                                                                 
CUDA_MODULE_LOADING set to: LAZY                                                                                        
GPU models and configuration:                
GPU 0: NVIDIA GeForce GTX 1080 Ti                                                                                       
GPU 1: NVIDIA GeForce GTX 1080 Ti
GPU 2: NVIDIA GeForce GTX 1080 Ti
GPU 3: NVIDIA GeForce GTX 1080 Ti
                               
Nvidia driver version: 530.41.03
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:                   46 bits physical, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          32
On-line CPU(s) list:             0-31
Vendor ID:                       GenuineIntel
Model name:                      Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
CPU family:                      6
Model:                           79
Thread(s) per core:              2
Core(s) per socket:              8
Socket(s):                       2
Stepping:                        1
CPU(s) scaling MHz:              54%
CPU max MHz:                     3000.0000
CPU min MHz:                     1200.0000
BogoMIPS:                        4200.44
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 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 pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap intel_pt xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts md_clear flush_l1d
Virtualization:                  VT-x
L1d cache:                       512 KiB (16 instances)
L1i cache:                       512 KiB (16 instances)
L2 cache:                        4 MiB (16 instances)
L3 cache:                        40 MiB (2 instances)
NUMA node(s):                    2
NUMA node0 CPU(s):               0-7,16-23
NUMA node1 CPU(s):               8-15,24-31
Vulnerability Itlb multihit:     KVM: Mitigation: VMX disabled
Vulnerability L1tf:              Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.23.5
[pip3] torch==2.0.1
[pip3] torchaudio==2.0.2
[pip3] torchdata==0.6.1
[pip3] triton==2.0.0
[conda] Could not collect

I think the CUDA libs might be relevant as well:

 % python3.10 -m pip freeze | grep nvidia
nvidia-cublas-cu11==11.10.3.66
nvidia-cuda-cupti-cu11==11.7.101
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99
nvidia-cudnn-cu11==8.5.0.96
nvidia-cufft-cu11==10.9.0.58
nvidia-curand-cu11==10.2.10.91
nvidia-cusolver-cu11==11.4.0.1
nvidia-cusparse-cu11==11.7.4.91
nvidia-nccl-cu11==2.14.3
nvidia-nvtx-cu11==11.7.91
@albertz
Copy link
Contributor Author

albertz commented Oct 22, 2023

#31412 might be related because this also seem to be about plan CuFFT caches.

@albertz
Copy link
Contributor Author

albertz commented Oct 22, 2023

Maybe also tensorflow/tensorflow#40814? It also has a crash in cufftXtMakePlanMany. Also maybe rwth-i6/returnn#1363.

Maybe this is some messup with CUDA / CuFFT versions?

@albertz
Copy link
Contributor Author

albertz commented Oct 23, 2023

Ok, after installing a clean Python 3.11 virtual env with PyTorch 2.1.0, I don't see the crash anymore, at least not for the same train step, or other train steps I have run so far.

So, maybe/probably this is not really a PyTorch bug, but sth with wrong CUDA libs versions.

I'm closing this now.

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