DataLoader worker (pid(s)) exited unexpectedly

Bilel_Touati: <p>When running my code I recieved this error message “ RuntimeError: DataLoader worker (pid(s) 8992) exited unexpectedly "  after training start</p>
<p>i use <strong>pytorch 1.12.1+cu113</strong><br>
NUM_Worker :  0<br>
batch_size :  1<br>
cuda :  True<br>
multi_gpu :  True<br>
image_size :  224<br>
can you help me</p>
<p>Model : resnet_split0 Experience : cross_validation<br>
self.dataset :  None<br>
videos_split :  [[‘SM686-7’ ‘train’]<br>
[‘LYI1079-2’ ‘train’]<br>
[‘GA817-1-8’ ‘train’]<br>
…<br>
[‘TA239-2’ ‘test’]<br>
[‘GM537-7’ ‘test’]<br>
[‘AM33-2’ ‘test’]]</p>
<p>videos_split :  [[‘SM686-7’ ‘train’]<br>
[‘LYI1079-2’ ‘train’]<br>
[‘GA817-1-8’ ‘train’]<br>
…<br>
[‘TA239-2’ ‘test’]<br>
[‘GM537-7’ ‘test’]<br>
[‘AM33-2’ ‘test’]]</p>
<p><strong><strong>Epoch_begin</strong></strong><br>
Epoch 1  : train</p>
<p>im in bloc loop <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"><br>
0 / 259398<br>
LGA881-1-2 9 0<br>
Traceback (most recent call last):<br>
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 1163, in _try_get_data<br>
data = self._data_queue.get(timeout=timeout)<br>
File “/usr/lib/python3.7/multiprocessing/queues.py”, line 113, in get<br>
return _ForkingPickler.loads(res)<br>
File “/usr/local/lib/python3.7/dist-packages/torch/multiprocessing/reductions.py”, line 297, in rebuild_storage_fd<br>
fd = df.detach()<br>
File “/usr/lib/python3.7/multiprocessing/resource_sharer.py”, line 57, in detach<br>
with _resource_sharer.get_connection(self._id) as conn:<br>
File “/usr/lib/python3.7/multiprocessing/resource_sharer.py”, line 87, in get_connection<br>
c = Client(address, authkey=process.current_process().authkey)<br>
File “/usr/lib/python3.7/multiprocessing/connection.py”, line 492, in Client<br>
c = SocketClient(address)<br>
File “/usr/lib/python3.7/multiprocessing/connection.py”, line 620, in SocketClient<br>
s.connect(address)<br>
FileNotFoundError: [Errno 2] No such file or directory</p>
<p>The above exception was the direct cause of the following exception:</p>
<p>Traceback (most recent call last):<br>
File “/content/drive/MyDrive/memoire-SSD/code/trainVal.py”, line 449, in <br>
main()<br>
File “/content/drive/MyDrive/memoire-SSD/code/trainVal.py”, line 446, in main<br>
run(args)<br>
File “/content/drive/MyDrive/memoire-SSD/code/trainVal.py”, line 348, in run<br>
trainFunc(**kwargsTr)<br>
File “/content/drive/MyDrive/memoire-SSD/code/trainVal.py”, line 30, in epochSeqTr<br>
for batch_idx,batch in enumerate(loader):<br>
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 681, in <strong>next</strong><br>
data = self._next_data()<br>
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 1359, in _next_data<br>
idx, data = self._get_data()<br>
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 1325, in _get_data<br>
success, data = self._try_get_data()<br>
File “/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py”, line 1176, in _try_get_data<br>
raise RuntimeError(‘DataLoader worker (pid(s) {}) exited unexpectedly’.format(pids_str)) from e<br>
RuntimeError: DataLoader worker (pid(s) 8992) exited unexpectedly</p>
<pre><code class="lang-auto"></code></pre>

ptrblck: <p>The code is failing in:</p>
<aside class="quote no-group" data-username="Bilel_Touati" data-post="1" data-topic="164690">
<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/bilel_touati/48/54437_2.png" class="avatar"> Bilel_Touati:</div>
<blockquote>
<p>File “/usr/lib/python3.7/multiprocessing/connection.py”, line 620, in SocketClient<br>
s.connect(address)<br>
FileNotFoundError: [Errno 2] No such file or directory</p>
</blockquote>
</aside>
<p>so maybe an if-guard would help:</p>
<pre data-code-wrap="python"><code class="lang-python">if __name__ == '__main__':
</code></pre>

Bilel_Touati: <aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="164690">
<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/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>The code is failing in:</p>
</blockquote>
</aside>
<p>i use google colab to run my code not in my desktop how i can set program package in colab ?</p>

Bilel_Touati: <p>i can set connection.py and add<br>
if <strong>name</strong> == “<strong>main</strong>”:<br>
main()</p>
<p>but the problem is not resolved<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/3/73639b8b494356ec1eb2b16db9efeea7adc965b8.png" data-download-href="https://discuss.pytorch.org/uploads/default/73639b8b494356ec1eb2b16db9efeea7adc965b8" title="error"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/3/73639b8b494356ec1eb2b16db9efeea7adc965b8_2_690x321.png" alt="error" data-base62-sha1="gsMjG2nZIeGCgdtEhV91aaUi4Ry" width="690" height="321" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/3/73639b8b494356ec1eb2b16db9efeea7adc965b8_2_690x321.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/3/73639b8b494356ec1eb2b16db9efeea7adc965b8_2_1035x481.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/7/3/73639b8b494356ec1eb2b16db9efeea7adc965b8.png 2x" data-dominant-color="F0EFEE"><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">error</span><span class="informations">1366×636 90.8 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>

Bilel_Touati: <p>have you encountered this problem in your projects?<br>
Anny solutions ?</p>

ptrblck: <p>No, I’ve never seen this issue in my setups. You should also not change any internal <code>connection.py</code> scripts from the <code>multiprocessing</code> package, but your main script.</p>

Bilel_Touati: <p>ok <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=12" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<p>after upgrade <strong>pymp</strong> with command :<strong>!pip install --upgrade pymp-pypi</strong> the error of directory is resolved<br>
but i can’t training my model</p>
<p>raise RuntimeError(‘DataLoader worker (pid(s) {}) exited unexpectedly’.format(pids_str)) from e<br>
RuntimeError: DataLoader worker (pid(s) 1833) exited unexpectedly<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/7/47da0b83ee33ae8ecb9155594523e6e23fb83349.png" data-download-href="https://discuss.pytorch.org/uploads/default/47da0b83ee33ae8ecb9155594523e6e23fb83349" title="screeeen"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/7/47da0b83ee33ae8ecb9155594523e6e23fb83349_2_690x325.png" alt="screeeen" data-base62-sha1="afD3HblCYmHuinvWxGqXfXtdUlb" width="690" height="325" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/7/47da0b83ee33ae8ecb9155594523e6e23fb83349_2_690x325.png, https://discuss.pytorch.org/uploads/default/optimized/3X/4/7/47da0b83ee33ae8ecb9155594523e6e23fb83349_2_1035x487.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/4/7/47da0b83ee33ae8ecb9155594523e6e23fb83349.png 2x" data-dominant-color="F4F0F1"><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">screeeen</span><span class="informations">1316×621 63.5 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>

Bilel_Touati: <p>error still persists</p>

bc060400164: <aside class="quote no-group" data-username="Bilel_Touati" data-post="7" data-topic="164690">
<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/bilel_touati/48/54437_2.png" class="avatar"> Bilel_Touati:</div>
<blockquote>
<p>timeError(‘DataLoader worker (pid(s) {}) exited unexpectedly’.format(pids_str)) from e<br>
RuntimeError: DataLoader worker (pid(s) 1833) exited un</p>
</blockquote>
</aside>
<p>Any Solution Getting the same Data Loader Error.</p>