Training with Pytorch DDP: DataLoader worker (pid 2945877) is killed by signal: Segmentation fault

Anita: <p>Hi,</p>
<p>I have implemented PyTorch DDP training for image classification through the official:</p><aside class="onebox githubblob" data-onebox-src="https://github.com/pytorch/examples/blob/main/imagenet/main.py">
  <header class="source">

      <a href="https://github.com/pytorch/examples/blob/main/imagenet/main.py" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/pytorch/examples/blob/main/imagenet/main.py" target="_blank" rel="noopener nofollow ugc">pytorch/examples/blob/main/imagenet/main.py</a></h4>


      <pre><code class="lang-py">import argparse
import os
import random
import shutil
import time
import warnings
from enum import Enum

import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.multiprocessing as mp
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.datasets as datasets
import torchvision.models as models
import torchvision.transforms as transforms
</code></pre>



  This file has been truncated. <a href="https://github.com/pytorch/examples/blob/main/imagenet/main.py" target="_blank" rel="noopener nofollow ugc">show original</a>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Training is crashing with <strong>RuntimeError: DataLoader worker (pid 2273997) is killed by signal: Segmentation fault.</strong> The errors comes up whenever i use num_workers&gt;0 at random epochs. When monitoring the CPU, the memory limit is not even being exceeded…</p>
<p>Things I have considered so far and that did not work:<br>
Lowered batch size<br>
Increased Docker shared memory<br>
Updated PyTorch version<br>
Verified that there is no corrupted file<br>
I am using custom dataset - I made sure I do not use any lists, everything is numpy array.</p>
<p>I focused in changing the prefetch_factor Dataloader parameter to <strong>prefetch_factor=1</strong>, and now the code seems to be running without issues with num_workers&gt;0.</p>
<p>Can someone please help me find out why this might be happening?</p>
<p>Thank you in advance.</p>

ptrblck: <p>It’s a bit hard to speculate why the segfault is raised. In case you can reproduce it in a reasonable amount of time, would it be possible to get a stacktrace from <code>gdb</code> via:</p>
<pre><code class="lang-python">gdb --args python script.py args
...
run
...
bt
</code></pre>

Anita: <p>Thank you for your prompt answer <a class="mention" href="/u/ptrblck">@ptrblck</a>. I am wondering can I <code>gdb</code>use this with torchrun?<br>
It shows the following error:</p>
<pre><code class="lang-auto">root@6ef594d11ca1:/home/nitmul/projects/meb-prostate-ai# gdb python
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/gdb/bugs/&gt;.
Find the GDB manual and other documentation resources online at:
&lt;http://www.gnu.org/software/gdb/documentation/&gt;.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...(no debugging symbols found)...done.
(gdb) run torchrun --nnodes=1 --nproc_per_node=3 prostateai/gleasonai/model_2/main.py
Starting program: /usr/local/bin/python torchrun --nnodes=1 --nproc_per_node=3 prostateai/gleasonai/model_2/main.py
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
/usr/local/bin/python: can't open file 'torchrun': [Errno 2] No such file or directory
[Inferior 1 (process 36691) exited with code 02]
</code></pre>

Anita: <p>hi <a class="mention" href="/u/ptrblck">@ptrblck</a>. I did what you suggested and the output from backtrace (bt) shows as follow:</p>
<pre><code class="lang-auto">
(gdb) bt
#0  0x00007f0c82e32d1f in __GI___select (nfds=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x7ffd3112e850) at ../sysdeps/unix/sysv/linux/select.c:41
#1  0x00000000005b97c4 in pysleep (secs=&lt;optimized out&gt;) at ../Modules/timemodule.c:1467
#2  time_sleep () at ../Modules/timemodule.c:235
#3  0x00000000005075bc in _PyCFunction_FastCallDict (kwargs=&lt;optimized out&gt;, nargs=&lt;optimized out&gt;, args=0x513c850, func_obj=&lt;built-in method sleep of module object at remote 0x7f0c81a66ef8&gt;) at ../Objects/methodobject.c:209
#4  _PyCFunction_FastCallKeywords (kwnames=&lt;optimized out&gt;, nargs=&lt;optimized out&gt;, stack=&lt;optimized out&gt;, func=&lt;optimized out&gt;) at ../Objects/methodobject.c:294
#5  call_function.lto_priv () at ../Python/ceval.c:4851
#6  0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#7  0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x513c688, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py, line 843, in _invoke_run (self=&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f0bb1ec5f10&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f0bb1eec340&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py'), 2: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '3', 'WORLD_SIZE': '3', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '3', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_...(truncated)) at ../Python/ceval.c:754
#8  _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#9  0x0000000000506d00 in fast_function.lto_priv () at ../Python/ceval.c:4992
#10 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#11 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#12 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x50ecce8, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py, line 709, in run (self=&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f0bb1ec5f10&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f0bb1eec340&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py'), 2: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '3', 'WORLD_SIZE': '3', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '3', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HA...(truncated)) at ../Python/ceval.c:754
#13 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#14 0x0000000000586641 in PyEval_EvalCodeEx (closure=&lt;optimized out&gt;, kwdefs=&lt;optimized out&gt;, defcount=1, defs=0x7f0b46271fe8, kwcount=0, kws=0x7f0c8313a060, argcount=&lt;optimized out&gt;, args=0x7f0bb1f2db18, locals=0x0, globals=&lt;optimized out&gt;, _co=&lt;optimized out&gt;) at ../Python/ceval.c:4187
#15 function_call.lto_priv () at ../Objects/funcobject.c:604
#16 0x000000000059d65e in PyObject_Call () at ../Objects/abstract.c:2261
#17 0x000000000050a752 in do_call_core (kwdict={}, 
    callargs=(&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f0bb1ec5f10&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f0bb1eec340&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py'), 2: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '3', 'WORLD_SIZE': '3', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '3', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HANDLING': '1', 'OMP_NUM_THREADS': '1', 'TORCHELASTIC_ERROR_FILE': '/tmp/torchelastic_w0i_nkib/none_v9f_c8k6/attempt_0/0/error.json'}, 1...(truncated), func=&lt;function at remote 0x7f0bb1edac80&gt;) at ../Python/ceval.c:5120
#18 _PyEval_EvalFrameDefault () at ../Python/ceval.c:3404
#19 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x50b84f8, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/metrics/api.py, line 125, in wrapper (args=(&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f0bb1ec5f10&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f0bb1eec340&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py'), 2: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '3', 'WORLD_SIZE': '3', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '3', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HA...(truncated)) at ../Python/ceval.c:754
#20 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#21 0x0000000000506d00 in fast_function.lto_priv () at ../Python/ceval.c:4992
#22 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#23 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#24 0x00000000005069c8 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x5131d98, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py, line 252, in launch_agent (config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=3, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f0c81d16400&gt;, __module__='torch.distributed.elastic.multiprocessing.api', from_str=&lt;classmethod at remote 0x7f0bb1fc9048&gt;, __doc__='An enumeration.', _member_names_=['NONE', 'OUT', 'ERR', 'ALL'], _member_map_={'NONE': &lt;...&gt;, 'OUT': &lt;Std(_value_=1, _name_='OUT', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0e48&gt;, 'ERR': &lt;Std(_value_=2, _name_='ERR', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0e88&gt;, 'ALL': &lt;Std(_value_=3, _name_='ALL', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0ec8&gt;}, _member_type_=&lt;type at remo...(truncated)) at ../Python/ceval.c:754
#25 _PyFunction_FastCall (globals=&lt;optimized out&gt;, nargs=85138840, args=&lt;optimized out&gt;, co=&lt;optimized out&gt;) at ../Python/ceval.c:4933
#26 fast_function.lto_priv () at ../Python/ceval.c:4968
#27 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#28 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#29 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x7f0bb1f19788, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py, line 131, in __call__ (self=&lt;elastic_launch(_config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=3, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f0c81d16400&gt;, __module__='torch.distributed.elastic.multiprocessing.api', fr---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
om_str=&lt;classmethod at remote 0x7f0bb1fc9048&gt;, __doc__='An enumeration.', _member_names_=['NONE', 'OUT', 'ERR', 'ALL'], _member_map_={'NONE': &lt;...&gt;, 'OUT': &lt;Std(_value_=1, _name_='OUT', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0e48&gt;, 'ERR': &lt;Std(_value_=2, _name_='ERR', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0e88&gt;, 'ALL': &lt;Std(_value_=3, _name_='ALL', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0ec8&gt;}, _mem...(truncated)) at ../Python/ceval.c:754
#30 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#31 0x00000000005062b2 in _PyFunction_FastCallDict () at ../Python/ceval.c:5075
#32 0x0000000000592461 in _PyObject_FastCallDict (kwargs=0x0, nargs=3, args=0x7ffd3112f6f0, func=&lt;function at remote 0x7f0bb1ee2158&gt;) at ../Objects/abstract.c:2310
#33 _PyObject_Call_Prepend (kwargs=0x0, args=&lt;optimized out&gt;, obj=&lt;optimized out&gt;, func=&lt;function at remote 0x7f0bb1ee2158&gt;) at ../Objects/abstract.c:2373
#34 method_call.lto_priv () at ../Objects/classobject.c:314
#35 0x00000000005479ef in PyObject_Call (kwargs=0x0, args=('-u', 'prostateai/gleasonai/model_2/main.py'), func=&lt;method at remote 0x7f0c80996388&gt;) at ../Objects/abstract.c:2261
#36 slot_tp_call () at ../Objects/typeobject.c:6207
#37 0x000000000059d65e in PyObject_Call () at ../Objects/abstract.c:2261
#38 0x000000000050a752 in do_call_core (kwdict=0x0, callargs=('-u', 'prostateai/gleasonai/model_2/main.py'), 
    func=&lt;elastic_launch(_config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=3, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f0c81d16400&gt;, __module__='torch.distributed.elastic.multiprocessing.api', from_str=&lt;classmethod at remote 0x7f0bb1fc9048&gt;, __doc__='An enumeration.', _member_names_=['NONE', 'OUT', 'ERR', 'ALL'], _member_map_={'NONE': &lt;...&gt;, 'OUT': &lt;Std(_value_=1, _name_='OUT', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0e48&gt;, 'ERR': &lt;Std(_value_=2, _name_='ERR', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0e88&gt;, 'ALL': &lt;Std(_value_=3, _name_='ALL', __objclass__=&lt;...&gt;) at remote 0x7f0bb1fb0ec8&gt;}, _member_type_=&lt;type at remote 0x9cd180&gt;, _value2member_map_={0: &lt;...&gt;, 1: &lt;...&gt;, 2: &lt;...&gt;, 3: &lt;...&gt;}, NONE=&lt;...&gt;, OUT=&lt;...&gt;, ERR=&lt;...&gt;, A...(truncated)) at ../Python/ceval.c:5120
#39 _PyEval_EvalFrameDefault () at ../Python/ceval.c:3404
#40 0x00000000005069c8 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x7f0bb1fe4828, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/run.py, line 713, in run (args=&lt;Namespace(nnodes='1', nproc_per_node='3', rdzv_backend='static', rdzv_endpoint='', rdzv_id='none', rdzv_conf='', standalone=False, max_restarts=0, monitor_interval=5, start_method='spawn', role='default', module=False, no_python=False, run_path=False, log_dir=None, redirects='0', tee='0', node_rank=0, master_addr='127.0.0.1', master_port=29500, training_script='prostateai/gleasonai/model_2/main.py', training_script_args=[]) at remote 0x7f0bb1eec128&gt;, config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=3, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f0c81d16400&gt;, __module__='torch.distributed.elastic.multi...(truncated)) at ../Python/ceval.c:754
#41 _PyFunction_FastCall (globals=&lt;optimized out&gt;, nargs=139688207599656, args=&lt;optimized out&gt;, co=&lt;optimized out&gt;) at ../Python/ceval.c:4933
#42 fast_function.lto_priv () at ../Python/ceval.c:4968
#43 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#44 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#45 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x7f0b46273708, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/run.py, line 719, in main (args=&lt;Namespace(nnodes='1', nproc_per_node='3', rdzv_backend='static', rdzv_endpoint='', rdzv_id='none', rdzv_conf='', standalone=False, max_restarts=0, monitor_interval=5, start_method='spawn', role='default', module=False, no_python=False, run_path=False, log_dir=None, redirects='0', tee='0', node_rank=0, master_addr='127.0.0.1', master_port=29500, training_script='prostateai/gleasonai/model_2/main.py', training_script_args=[]) at remote 0x7f0bb1eec128&gt;)) at ../Python/ceval.c:754
#46 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#47 0x0000000000586641 in PyEval_EvalCodeEx (closure=&lt;optimized out&gt;, kwdefs=&lt;optimized out&gt;, defcount=1, defs=0x7f0c808abbf8, kwcount=0, kws=0x7f0c8313a060, argcount=&lt;optimized out&gt;, args=0x7f0c8313a060, locals=0x0, globals=&lt;optimized out&gt;, _co=&lt;optimized out&gt;) at ../Python/ceval.c:4187
#48 function_call.lto_priv () at ../Objects/funcobject.c:604
#49 0x000000000059d65e in PyObject_Call () at ../Objects/abstract.c:2261
#50 0x000000000050a752 in do_call_core (kwdict={}, callargs=(), func=&lt;function at remote 0x7f0bb1ee2840&gt;) at ../Python/ceval.c:5120
#51 _PyEval_EvalFrameDefault () at ../Python/ceval.c:3404
#52 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0x13a1c18, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py, line 345, in wrapper (args=(), kwargs={})) at ../Python/ceval.c:754
#53 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#54 0x0000000000506d00 in fast_function.lto_priv () at ../Python/ceval.c:4992
#55 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#56 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#57 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0x11ef448, for file /usr/local/bin/torchrun, line 33, in &lt;module&gt; ()) at ../Python/ceval.c:754
#58 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#59 0x0000000000508103 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=&lt;optimized out&gt;, globals=&lt;optimized out&gt;, _co=&lt;optimized out&gt;) at ../Python/ceval.c:4187
#60 PyEval_EvalCode (co=&lt;optimized out&gt;, globals=&lt;optimized out&gt;, locals=&lt;optimized out&gt;) at ../Python/ceval.c:731
#61 0x0000000000634c32 in run_mod () at ../Python/pythonrun.c:1025
#62 0x0000000000634ce7 in PyRun_FileExFlags () at ../Python/pythonrun.c:978
#63 0x000000000063849f in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:419
#64 0x0000000000638675 in PyRun_AnyFileExFlags () at ../Python/pythonrun.c:81
#65 0x0000000000639041 in run_file (p_cf=0x7ffd3113036c, filename=&lt;optimized out&gt;, fp=&lt;optimized out&gt;) at ../Modules/main.c:340
#66 Py_Main () at ../Modules/main.c:810
#67 0x00000000004ad1f0 in main (argc=5, argv=0x7ffd31130568) at ../Programs/python.c:69
</code></pre>

ptrblck: <p>Your backtrace points to a <code>sleep</code> operation and doesn’t show the segfault:</p>
<pre><code class="lang-auto">#0  0x00007f0c82e32d1f in __GI___select (nfds=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x7ffd3112e850) at ../sysdeps/unix/sysv/linux/select.c:41
#1  0x00000000005b97c4 in pysleep (secs=&lt;optimized out&gt;) at ../Modules/timemodule.c:1467
#2  time_sleep () at ../Modules/timemodule.c:235
#3  0x00000000005075bc in _PyCFunction_FastCallDict (kwargs=&lt;optimized out&gt;, nargs=&lt;optimized out&gt;, args=0x513c850, func_obj=&lt;built-in method sleep of module object at remote 0x7f0c81a66ef8&gt;) at ../Objects/methodobject.c:209
#4  _PyCFunction_FastCallKeywords (kwnames=&lt;optimized out&gt;, nargs=&lt;optimized out&gt;, stack=&lt;optimized out&gt;, func=&lt;optimized out&gt;) at ../Objects/methodobject.c:294
#5  call_function.lto_priv () at ../Python/ceval.c:4851
#6  0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#7  0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
</code></pre>
<p>Did you add the <code>sleep</code> or did you just break at a random op?</p>

Anita: <p>Hii <a class="mention" href="/u/ptrblck">@ptrblck</a>, sometimes even though I get the segmentation fault the processes keep still going, that why for the previous output I had to manually stop them.</p>
<p>However, the below output from the bt is when the segfault showed and I did not interrupt the processes:<br>
I would really appreaciate if you could check it out and let me know your thoughts.</p>
<pre><code class="lang-auto">(gdb) bt
#0  0x00007f4c03e84d1f in __GI___select (nfds=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x7ffee3ed8c90) at ../sysdeps/unix/sysv/linux/select.c:41
#1  0x00000000005b97c4 in pysleep (secs=&lt;optimized out&gt;) at ../Modules/timemodule.c:1467
#2  time_sleep () at ../Modules/timemodule.c:235
#3  0x00000000005075bc in _PyCFunction_FastCallDict (kwargs=&lt;optimized out&gt;, nargs=&lt;optimized out&gt;, args=0x4c63070, func_obj=&lt;built-in method sleep of module object at remote 0x7f4c02ab8ef8&gt;) at ../Objects/methodobject.c:209
#4  _PyCFunction_FastCallKeywords (kwnames=&lt;optimized out&gt;, nargs=&lt;optimized out&gt;, stack=&lt;optimized out&gt;, func=&lt;optimized out&gt;) at ../Objects/methodobject.c:294
#5  call_function.lto_priv () at ../Python/ceval.c:4851
#6  0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#7  0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x4c62ea8, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py, line 843, in _invoke_run (self=&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f4b32fd28e0&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f4b32f82688&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '2', 'WORLD_SIZE': '2', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '2', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HANDLING': '1', 'OMP_NUM_THREADS': '1', 'TORC...(truncated)) at ../Python/ceval.c:754
#8  _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#9  0x0000000000506d00 in fast_function.lto_priv () at ../Python/ceval.c:4992
#10 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#11 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#12 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x4c3d568, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py, line 709, in run (self=&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f4b32fd28e0&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f4b32f82688&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '2', 'WORLD_SIZE': '2', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '2', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HANDLING': '1', 'OMP_NUM_THREADS': '1', 'TORCHELASTIC...(truncated)) at ../Python/ceval.c:754
#13 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#14 0x0000000000586641 in PyEval_EvalCodeEx (closure=&lt;optimized out&gt;, kwdefs=&lt;optimized out&gt;, defcount=1, defs=0x7f4b32fc5958, kwcount=0, kws=0x7f4c0418c060, argcount=&lt;optimized out&gt;, args=0x7f4ac72c1760, locals=0x0, globals=&lt;optimized out&gt;, _co=&lt;optimized out&gt;) at ../Python/ceval.c:4187
#15 function_call.lto_priv () at ../Objects/funcobject.c:604
#16 0x000000000059d65e in PyObject_Call () at ../Objects/abstract.c:2261
#17 0x000000000050a752 in do_call_core (kwdict={}, 
    callargs=(&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f4b32fd28e0&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f4b32f82688&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '2', 'WORLD_SIZE': '2', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '2', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HANDLING': '1', 'OMP_NUM_THREADS': '1', 'TORCHELASTIC_ERROR_FILE': '/tmp/torchelastic_sd2v1fbe/none_k3qyzzyt/attempt_0/0/error.json'}, 1: {'LOCAL_RANK': '1', 'RANK': '1', 'GROUP_RANK': '0...(truncated), func=&lt;function at remote 0x7f4b32f69d08&gt;) at ../Python/ceval.c:5120
#18 _PyEval_EvalFrameDefault () at ../Python/ceval.c:3404
#19 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x4bcd358, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/metrics/api.py, line 125, in wrapper (args=(&lt;LocalElasticAgent(_worker_group=&lt;WorkerGroup at remote 0x7f4b32fd28e0&gt;, _remaining_restarts=0, _store=&lt;torch._C._distributed_c10d.PrefixStore at remote 0x7f4b32f82688&gt;, _exit_barrier_timeout=300, _total_execution_time=0, _start_method='spawn', _pcontext=&lt;SubprocessContext(name='default', entrypoint='/usr/bin/python3', args={0: ('-u', 'prostateai/gleasonai/model_2/main.py'), 1: ('-u', 'prostateai/gleasonai/model_2/main.py')}, envs={0: {'LOCAL_RANK': '0', 'RANK': '0', 'GROUP_RANK': '0', 'ROLE_RANK': '0', 'ROLE_NAME': 'default', 'LOCAL_WORLD_SIZE': '2', 'WORLD_SIZE': '2', 'GROUP_WORLD_SIZE': '1', 'ROLE_WORLD_SIZE': '2', 'MASTER_ADDR': '127.0.0.1', 'MASTER_PORT': '29500', 'TORCHELASTIC_RESTART_COUNT': '0', 'TORCHELASTIC_MAX_RESTARTS': '0', 'TORCHELASTIC_RUN_ID': 'none', 'TORCHELASTIC_USE---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
_AGENT_STORE': 'True', 'NCCL_ASYNC_ERROR_HANDLING': '1', 'OMP_NUM_THREADS': '1', 'TORCHELASTIC...(truncated)) at ../Python/ceval.c:754
#20 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#21 0x0000000000506d00 in fast_function.lto_priv () at ../Python/ceval.c:4992
#22 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#23 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#24 0x00000000005069c8 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x4c49e28, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py, line 252, in launch_agent (config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=2, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f4c02d67488&gt;, __module__='torch.distributed.elastic.multiprocessing.api', from_str=&lt;classmethod at remote 0x7f4b33051eb8&gt;, __doc__='An enumeration.', _member_names_=['NONE', 'OUT', 'ERR', 'ALL'], _member_map_={'NONE': &lt;...&gt;, 'OUT': &lt;Std(_value_=1, _name_='OUT', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0bc8&gt;, 'ERR': &lt;Std(_value_=2, _name_='ERR', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0c08&gt;, 'ALL': &lt;Std(_value_=3, _name_='ALL', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0c48&gt;}, _member_type_=&lt;type at remo...(truncated)) at ../Python/ceval.c:754
#25 _PyFunction_FastCall (globals=&lt;optimized out&gt;, nargs=79994408, args=&lt;optimized out&gt;, co=&lt;optimized out&gt;) at ../Python/ceval.c:4933
#26 fast_function.lto_priv () at ../Python/ceval.c:4968
#27 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#28 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#29 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x7f4b32fe15b8, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py, line 131, in __call__ (self=&lt;elastic_launch(_config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=2, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f4c02d67488&gt;, __module__='torch.distributed.elastic.multiprocessing.api', from_str=&lt;classmethod at remote 0x7f4b33051eb8&gt;, __doc__='An enumeration.', _member_names_=['NONE', 'OUT', 'ERR', 'ALL'], _member_map_={'NONE': &lt;...&gt;, 'OUT': &lt;Std(_value_=1, _name_='OUT', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0bc8&gt;, 'ERR': &lt;Std(_value_=2, _name_='ERR', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0c08&gt;, 'ALL': &lt;Std(_value_=3, _name_='ALL', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0c48&gt;}, _mem...(truncated)) at ../Python/ceval.c:754
#30 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#31 0x00000000005062b2 in _PyFunction_FastCallDict () at ../Python/ceval.c:5075
#32 0x0000000000592461 in _PyObject_FastCallDict (kwargs=0x0, nargs=3, args=0x7ffee3ed9b30, func=&lt;function at remote 0x7f4b32f7a0d0&gt;) at ../Objects/abstract.c:2310
#33 _PyObject_Call_Prepend (kwargs=0x0, args=&lt;optimized out&gt;, obj=&lt;optimized out&gt;, func=&lt;function at remote 0x7f4b32f7a0d0&gt;) at ../Objects/abstract.c:2373
#34 method_call.lto_priv () at ../Objects/classobject.c:314
#35 0x00000000005479ef in PyObject_Call (kwargs=0x0, args=('-u', 'prostateai/gleasonai/model_2/main.py'), func=&lt;method at remote 0x7f4c019d12c8&gt;) at ../Objects/abstract.c:2261
#36 slot_tp_call () at ../Objects/typeobject.c:6207
#37 0x000000000059d65e in PyObject_Call () at ../Objects/abstract.c:2261
#38 0x000000000050a752 in do_call_core (kwdict=0x0, callargs=('-u', 'prostateai/gleasonai/model_2/main.py'), 
    func=&lt;elastic_launch(_config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=2, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f4c02d67488&gt;, __module__='torch.distributed.elastic.multiprocessing.api', from_str=&lt;classmethod at remote 0x7f4b33051eb8&gt;, __doc__='An enumeration.', _member_names_=['NONE', 'OUT', 'ERR', 'ALL'], _member_map_={'NONE': &lt;...&gt;, 'OUT': &lt;Std(_value_=1, _name_='OUT', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0bc8&gt;, 'ERR': &lt;Std(_value_=2, _name_='ERR', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0c08&gt;, 'ALL': &lt;Std(_value_=3, _name_='ALL', __objclass__=&lt;...&gt;) at remote 0x7f4b32fd0c48&gt;}, _member_type_=&lt;type at remote 0x9cd180&gt;, _value2member_map_={0: &lt;...&gt;, 1: &lt;...&gt;, 2: &lt;...&gt;, 3: &lt;...&gt;}, NONE=&lt;...&gt;, OUT=&lt;...&gt;, ERR=&lt;...&gt;, A...(truncated)) at ../Python/ceval.c:5120
#39 _PyEval_EvalFrameDefault () at ../Python/ceval.c:3404
#40 0x00000000005069c8 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x7f4b32f7f048, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/run.py, line 713, in run (args=&lt;Namespace(nnodes='1', nproc_per_node='2', rdzv_backend='static', rdzv_endpoint='', rdzv_id='none', rdzv_conf='', standalone=False, max_restarts=0, monitor_interval=5, start_method='spawn---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
', role='default', module=False, no_python=False, run_path=False, log_dir=None, redirects='0', tee='0', node_rank=0, master_addr='127.0.0.1', master_port=29500, training_script='prostateai/gleasonai/model_2/main.py', training_script_args=[]) at remote 0x7f4b32f82470&gt;, config=&lt;LaunchConfig(min_nodes=1, max_nodes=1, nproc_per_node=2, run_id='none', role='default', rdzv_endpoint='127.0.0.1:29500', rdzv_backend='static', rdzv_configs={'rank': 0, 'timeout': 900}, rdzv_timeout=-1, max_restarts=0, monitor_interval=5, start_method='spawn', log_dir=None, redirects=&lt;Std(_value_=0, _name_='NONE', __objclass__=&lt;EnumMeta(_generate_next_value_=&lt;function at remote 0x7f4c02d67488&gt;, __module__='torch.distributed.elastic.multi...(truncated)) at ../Python/ceval.c:754
#41 _PyFunction_FastCall (globals=&lt;optimized out&gt;, nargs=139960954384456, args=&lt;optimized out&gt;, co=&lt;optimized out&gt;) at ../Python/ceval.c:4933
#42 fast_function.lto_priv () at ../Python/ceval.c:4968
#43 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#44 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#45 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, 
    f=Frame 0x7f4b3301ea48, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/run.py, line 719, in main (args=&lt;Namespace(nnodes='1', nproc_per_node='2', rdzv_backend='static', rdzv_endpoint='', rdzv_id='none', rdzv_conf='', standalone=False, max_restarts=0, monitor_interval=5, start_method='spawn', role='default', module=False, no_python=False, run_path=False, log_dir=None, redirects='0', tee='0', node_rank=0, master_addr='127.0.0.1', master_port=29500, training_script='prostateai/gleasonai/model_2/main.py', training_script_args=[]) at remote 0x7f4b32f82470&gt;)) at ../Python/ceval.c:754
#46 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#47 0x0000000000586641 in PyEval_EvalCodeEx (closure=&lt;optimized out&gt;, kwdefs=&lt;optimized out&gt;, defcount=1, defs=0x7f4c018fdae0, kwcount=0, kws=0x7f4c0418c060, argcount=&lt;optimized out&gt;, args=0x7f4c0418c060, locals=0x0, globals=&lt;optimized out&gt;, _co=&lt;optimized out&gt;) at ../Python/ceval.c:4187
#48 function_call.lto_priv () at ../Objects/funcobject.c:604
#49 0x000000000059d65e in PyObject_Call () at ../Objects/abstract.c:2261
#50 0x000000000050a752 in do_call_core (kwdict={}, callargs=(), func=&lt;function at remote 0x7f4b32f7a7b8&gt;) at ../Python/ceval.c:5120
#51 _PyEval_EvalFrameDefault () at ../Python/ceval.c:3404
#52 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0x4710f18, for file /usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py, line 345, in wrapper (args=(), kwargs={})) at ../Python/ceval.c:754
#53 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#54 0x0000000000506d00 in fast_function.lto_priv () at ../Python/ceval.c:4992
#55 0x00000000005076ed in call_function.lto_priv () at ../Python/ceval.c:4872
#56 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
#57 0x0000000000504fd4 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0xd7bcc8, for file /usr/local/bin/torchrun, line 33, in &lt;module&gt; ()) at ../Python/ceval.c:754
#58 _PyEval_EvalCodeWithName.lto_priv.1836 () at ../Python/ceval.c:4166
#59 0x0000000000508103 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=&lt;optimized out&gt;, globals=&lt;optimized out&gt;, _co=&lt;optimized out&gt;) at ../Python/ceval.c:4187
#60 PyEval_EvalCode (co=&lt;optimized out&gt;, globals=&lt;optimized out&gt;, locals=&lt;optimized out&gt;) at ../Python/ceval.c:731
#61 0x0000000000634c32 in run_mod () at ../Python/pythonrun.c:1025
#62 0x0000000000634ce7 in PyRun_FileExFlags () at ../Python/pythonrun.c:978
#63 0x000000000063849f in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:419
#64 0x0000000000638675 in PyRun_AnyFileExFlags () at ../Python/pythonrun.c:81
#65 0x0000000000639041 in run_file (p_cf=0x7ffee3eda7ac, filename=&lt;optimized out&gt;, fp=&lt;optimized out&gt;) at ../Modules/main.c:340
#66 Py_Main () at ../Modules/main.c:810
#67 0x00000000004ad1f0 in main (argc=5, argv=0x7ffee3eda9a8) at ../Programs/python.c:69

</code></pre>

Anita: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> also when I check the output with py-bt it shows as:</p>
<pre><code class="lang-auto">
(gdb) 
(gdb) py-bt
Traceback (most recent call first):
  &lt;built-in method sleep of module object at remote 0x7f4c02ab8ef8&gt;
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py", line 843, in _invoke_run
    time.sleep(monitor_interval)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py", line 709, in run
    result = self._invoke_run(role)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/metrics/api.py", line 125, in wrapper
    result = f(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py", line 252, in launch_agent
    result = agent.run()
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py", line 131, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/run.py", line 713, in run
    )(*cmd_args)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/run.py", line 719, in main
    run(args)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 345, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/bin/torchrun", line 33, in &lt;module&gt;
    sys.exit(load_entry_point('torch==1.10.2+cu113', 'console_scripts', 'torchrun')())
</code></pre>

Anita: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> also some other outputs, if it is helpful to you. Thank you in advance.</p>
<pre><code class="lang-auto">
(gdb) info threads
  Id   Target Id         Frame 
* 1    Thread 0x7f4c04378740 (LWP 7371) "torchrun" 0x00000000005092a4 in _PyEval_EvalFrameDefault () at ../Python/ceval.c:3335
  2    Thread 0x7f4b0026e700 (LWP 7414) "torchrun" 0x00007f4c03e82bb9 in __GI___poll (fds=0x7f4b04001030, nfds=6, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
  3    Thread 0x7f4b00a6f700 (LWP 7415) "torchrun" 0x00007f4c03e82bb9 in __GI___poll (fds=0x7f4ac0000b40, nfds=2, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29


(gdb) t a a py-bt

Thread 3 (Thread 0x7f4b00a6f700 (LWP 7415)):
Unable to locate python frame

Thread 2 (Thread 0x7f4b0026e700 (LWP 7414)):
Unable to locate python frame

Thread 1 (Thread 0x7f4c04378740 (LWP 7371)):
Traceback (most recent call first):
  &lt;built-in method sleep of module object at remote 0x7f4c02ab8ef8&gt;
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py", line 843, in _invoke_run
    time.sleep(monitor_interval)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/agent/server/api.py", line 709, in run
    result = self._invoke_run(role)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/metrics/api.py", line 125, in wrapper
    result = f(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py", line 252, in launch_agent
    result = agent.run()
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/launcher/api.py", line 131, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/run.py", line 713, in run
    )(*cmd_args)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/run.py", line 719, in main
    run(args)
  File "/usr/local/lib/python3.6/dist-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 345, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/bin/torchrun", line 33, in &lt;module&gt;
    sys.exit(load_entry_point('torch==1.10.2+cu113', 'console_scripts', 'torchrun')())


(gdb) py-list
  28    globals().setdefault('load_entry_point', importlib_load_entry_point)
  29    
  30    
  31    if __name__ == '__main__':
  32        sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
 &gt;33        sys.exit(load_entry_point('torch==1.10.2+cu113', 'console_scripts', 'torchrun')())


</code></pre>

ptrblck: <p>All stacktraces just point to the <code>sleep</code> calls and do not show the segfault.</p>
<aside class="quote no-group" data-username="Anita" data-post="7" data-topic="173785">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/anita/48/56469_2.png" class="avatar"> Anita:</div>
<blockquote>
<p>sometimes even though I get the segmentation fault the processes keep still going, that why for the previous output I had to manually stop them.</p>
</blockquote>
</aside>
<p>Do you still see the <code>DataLoader</code> error claiming a worker was killed or is the entire script just running fine?</p>