Skip to content

Dataloader with multiprocessing_context="spawn" fails with multiprocessing.ValueΒ #105514

Closed

Description

@pritamdamania87

πŸ› Describe the bug

If you pass a multiprocessing.Value to the dataloader workers and access it from both the main process and the workers, this results in a segmentation fault.

Code to repro:

import torch
import multiprocessing
from functools import partial

ITERS = 10

class MyDataset(torch.utils.data.Dataset):
  def __getitem__(self, idx):
    print(f"value: {self.mp_value.value}")
    return idx

  def __len__(self):
    return ITERS


def worker_init(mp_value, worker_id):
  worker_info = torch.utils.data.get_worker_info()
  dataset = worker_info.dataset
  dataset.mp_value = mp_value

if __name__ == '__main__':
  ds = MyDataset()
  mp_value = multiprocessing.Value("i", -1)
  loader = torch.utils.data.DataLoader(ds, num_workers=16, worker_init_fn=partial(worker_init, mp_value), multiprocessing_context=multiprocessing.get_context("spawn"))
  for data in loader:
    mp_value.value = data

Output:

ERROR: Unexpected segmentation fault encountered in worker.
Traceback (most recent call last):
  File "torch/utils/data/dataloader.py", line 1132, in _try_get_data
    data = self._data_queue.get(timeout=timeout)
  File "multiprocessing/queues.py", line 107, in get
    if not self._poll(timeout):
  File "multiprocessing/connection.py", line 257, in poll
    return self._poll(timeout)
  File "multiprocessing/connection.py", line 424, in _poll
    r = wait([self], timeout)
  File "multiprocessing/connection.py", line 931, in wait
    ready = selector.select(timeout)
  File "selectors.py", line 415, in select
    fd_event_list = self._selector.poll(timeout)
  File "torch/utils/data/_utils/signal_handling.py", line 66, in handler
    _error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 954083) is killed by signal: Segmentation fault. 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/tmp/testdataset.py", line 25, in <module>
    for data in loader:
  File "torch/utils/data/dataloader.py", line 633, in __next__
    data = self._next_data()
  File "torch/utils/data/dataloader.py", line 1328, in _next_data
    idx, data = self._get_data()
  File "torch/utils/data/dataloader.py", line 1294, in _get_data
    success, data = self._try_get_data()
  File "torch/utils/data/dataloader.py", line 1145, in _try_get_data
    raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
RuntimeError: DataLoader worker (pid(s) 954083) exited unexpectedly

However, similar code that just uses torch.multiprocessing.spawn without the Dataloader seems to work fine if multiprocessing.Value is passed in. Seems like this is a problem with Dataloader + multiprocessing spawn. Dataloader with multiprocessing fork works fine for this example.

Versions

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] mypy-protobuf==3.3.0
[pip3] numpy==1.23.5
[pip3] pytorch-triton==2.1.0+46672772b4
[pip3] pytorch3d==0.6.2
[pip3] torch==2.0.1+1686355048.cuda120.cudnn891.nccl218.ap
[pip3] torch-mlir==1689007104-8a8e1baf
[pip3] torch-scatter==2.1.0
[pip3] torch-tb-profiler==0.4.1
[pip3] torchfile==0.1.0
[pip3] torchmetrics==0.11.4
[pip3] torchvision==0.15.2a0+fa99a53
[pip3] triton==2.1.0
[conda] magma-cuda121 2.6.1 1 pytorch
[conda] mkl 2020.4 h726a3e6_304 conda-forge
[conda] mkl-include 2023.1.0 h84fe81f_48680 conda-forge
[conda] numpy 1.23.5 py38h7042d01_0 conda-forge
[conda] pytorch3d 0.6.2 pypi_0 pypi
[conda] torch 2.0.1+1687647636.cuda120.cudnn891.nccl218.ap pypi_0 pypi
[conda] torch-mlir 1689007104-8a8e1baf pypi_0 pypi
[conda] torch-scatter 2.1.0 pypi_0 pypi
[conda] torch-tb-profiler 0.4.1 pypi_0 pypi
[conda] torchfile 0.1.0 pypi_0 pypi
[conda] torchmetrics 0.11.4 pyhd8ed1ab_0 conda-forge
[conda] torchvision 0.15.2a0+fa99a53 pypi_0 pypi
[conda] triton 2.1.0 pypi_0 pypi

cc @ezyang @gchanan @zou3519 @VitalyFedyunin

Activity

  1. albanD commented on Jul 19, 2023

    @albanD
    Collaborator

    This seems to be very related to #29855
    The c++ stack trace is exactly the same:

    #0  0x00007ffff7d79f2f in __new_sem_wait_fast (definitive_result=1, sem=0x7fffea280000 <scanstring_unicode+852>)
        at /usr/src/debug/glibc-2.36-9.fc37.x86_64/nptl/sem_waitcommon.c:141
    #1  __new_sem_trywait (sem=0x7fffea280000 <scanstring_unicode+852>) at sem_wait.c:81
    #2  0x00007fffea11a008 in _multiprocessing_SemLock_acquire_impl (self=self@entry=0x7fff0a09fdd0, 
        blocking=blocking@entry=1, timeout_obj=None)
        at /home/albandes/local/installs/python3.11/debug/source/Modules/_multiprocessing/semaphore.c:342
    #3  0x00007fffea11a2c5 in _multiprocessing_SemLock_acquire (self=0x7fff0a09fdd0, args=<optimized out>, 
        args@entry=0x7ffff7fb5668, nargs=nargs@entry=0, kwnames=kwnames@entry=0x0)
        at /home/albandes/local/installs/python3.11/debug/source/Modules/_multiprocessing/clinic/semaphore.c.h:123
    #4  0x00000000004e5913 in cfunction_vectorcall_FASTCALL_KEYWORDS (
        func=<built-in method acquire of _multiprocessing.SemLock object at remote 0x7fff0a09fdd0>, args=0x7ffff7fb5668, 
        nargsf=<optimized out>, kwnames=0x0) at Objects/methodobject.c:443
    #5  0x00000000004a2bcf in _PyObject_VectorcallTstate (tstate=0x8f6618 <_PyRuntime+166328>, 
        callable=callable@entry=<built-in method acquire of _multiprocessing.SemLock object at remote 0x7fff0a09fdd0>, 
        args=args@entry=0x7ffff7fb5668, nargsf=9223372036854775808, kwnames=kwnames@entry=0x0)
        at ./Include/internal/pycore_call.h:92
    #6  0x00000000004a2c9a in PyObject_Vectorcall (
        callable=callable@entry=<built-in method acquire of _multiprocessing.SemLock object at remote 0x7fff0a09fdd0>, 
        args=args@entry=0x7ffff7fb5668, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:299
    #7  0x000000000057d642 in _PyEval_EvalFrameDefault (tstate=0x8f6618 <_PyRuntime+166328>, frame=0x7ffff7fb5608, 
        throwflag=<optimized out>) at Python/ceval.c:4774
    #8  0x00000000005814eb in _PyEval_EvalFrame (tstate=tstate@entry=0x8f6618 <_PyRuntime+166328>, 
        frame=frame@entry=0x7ffff7fb5608, throwflag=throwflag@entry=0) at ./Include/internal/pycore_ceval.h:73
    #9  0x00000000005815ec in _PyEval_Vector (tstate=0x8f6618 <_PyRuntime+166328>, func=0x7fff0a093d80, 
        locals=locals@entry=0x0, args=0x7fffffffcc78, argcount=<optimized out>, kwnames=0x0) at Python/ceval.c:6439
    #10 0x00000000004a28ab in _PyFunction_Vectorcall (func=<optimized out>, stack=<optimized out>, 
        nargsf=<optimized out>, kwnames=<optimized out>) at Objects/call.c:393
    #11 0x00000000004a2bcf in _PyObject_VectorcallTstate (tstate=0x8f6618 <_PyRuntime+166328>, 
        callable=callable@entry=<function at remote 0x7fff0a093d80>, args=args@entry=0x7fffffffcc78, 
        nargsf=nargsf@entry=9223372036854775809, kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92
    
    

    And the python stack is similar

    Traceback (most recent call first):
      <built-in method acquire of _multiprocessing.SemLock object at remote 0x7fff0a09fdd0>
      File "<string>", line 3, in getvalue
      File "/home/albandes/local/pytorch/3.11_debug_source/test/foo.py", line 9, in __getitem__
        print(f"value: {self.mp_value.value}")
      File "/home/albandes/local/pytorch/3.11_debug_source/torch/utils/data/_utils/fetch.py", line 51, in <listcomp>
        data = [self.dataset[idx] for idx in possibly_batched_index]
      File "/home/albandes/local/pytorch/3.11_debug_source/torch/utils/data/_utils/fetch.py", line 51, in fetch
        data = [self.dataset[idx] for idx in possibly_batched_index]
      File "/home/albandes/local/pytorch/3.11_debug_source/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
        data = fetcher.fetch(index)
      File "/home/albandes/local/installs/python3.11/debug/install/lib/python3.11/multiprocessing/process.py", line 108, in run
        self._target(*self._args, **self._kwargs)
      File "/home/albandes/local/installs/python3.11/debug/install/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
        self.run()
      File "/home/albandes/local/installs/python3.11/debug/install/lib/python3.11/multiprocessing/spawn.py", line 133, in _main
        return self._bootstrap(parent_sentinel)
      File "/home/albandes/local/installs/python3.11/debug/install/lib/python3.11/multiprocessing/spawn.py", line 120, in spawn_main
        exitcode = _main(fd, parent_sentinel)
      File "<string>", line 1, in <module>
    
  2. ezhang887 commented on Jul 19, 2023

    @ezhang887
    Contributor

    This diff fixes the issue for me:

    @@ -20,7 +20,8 @@ def worker_init(mp_value, worker_id):
    
     if __name__ == '__main__':
       ds = MyDataset()
    -  mp_value = multiprocessing.Value("i", -1)
    +  ctx = multiprocessing.get_context("spawn")
    +  mp_value = ctx.Value("i", -1)
       loader = torch.utils.data.DataLoader(ds, num_workers=16, worker_init_fn=partial(worker_init, mp_value), multiprocessing_context=multiprocessing.get_context("spawn"))
       for data in loader:
         mp_value.value = data
    

    This is what I think is happening (I'm using Python 3.8, not sure if this applies to different python versions):

    • Turns out SemLock's (a named semaphore used internally in Value) internal behavior changes a bit depending on the multiprocessing start method.
    • If the context of the Value is fork it sets this unlink_now to True: link.
    • If unlink_now is True, then the name of the named semaphore's name will be NULL and sem_unlink is called immediately: link. This leads to not being able to re-construct the named semaphore correctly when un-pickling. But this only happens if the context of the Value is fork so there's no pickling then so that's OK.
    • As a result of ^ we need to explicitly make sure that the mp.Value is created with a spawn context.
  3. ezhang887 commented on Jul 19, 2023

    @ezhang887
    Contributor

    @albanD Looks like the following diff might also fix #29855? It seems to fix the example there for me (I'm using Python 3.8, not sure if the same applies to different python versions)

    16,17c16
    <     ctx = mp.get_context("spawn")
    <     barrier = ctx.Barrier(num_procs)
    ---
    >     barrier = mp.Barrier(num_procs)
    
  4. albanD commented on Jul 19, 2023

    @albanD
    Collaborator

    Not sure what you mean?
    Where do you apply this diff?

  5. ezhang887 commented on Jul 19, 2023

    @ezhang887
    Contributor

    Not sure what you mean? Where do you apply this diff?

    Basically when using "spawn" doing something like ctx = mp.get_context("spawn"); value = ctx.Value(...) instead of value = mp.Value(...) fixes the segfault in the above example for me.

    And the same thing for the barrier example in #29855, doing ctx = mp.get_context("spawn"); barrier = ctx.Barrier(...) instead of barrier = mp.Barrier(...) fixes it for me.

  6. albanD commented on Jul 19, 2023

    @albanD
    Collaborator

    But it is still something we're doing wrong on our end as when torch is not involved, either works fine.

  7. albanD commented on Jul 19, 2023

    @albanD
    Collaborator

    btw another way to fix this here is to set multiprocessing.set_start_method("spawn") before creating your object.
    I guess the problem is that the user Barrier/Value is created in a fork context (the default) but then used in a spawn context and thus the segfault?

  8. ezhang887 commented on Jul 19, 2023

    @ezhang887
    Contributor

    btw another way to fix this here is to set multiprocessing.set_start_method("spawn") before creating your object.

    Yup also saw that, just wanted to avoid multiprocessing.set_start_method("spawn") and use the contexts instead since it seemed cleaner.

    I guess the problem is that the user Barrier/Value is created in a fork context (the default) but then used in a spawn context and thus the segfault?

    Yup this was what I was thinking.

  9. added
    triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
    and removed on Jul 24, 2023
  10. albanD commented on Jul 25, 2023

    @albanD
    Collaborator

    btw this is a know upstream problem in CPython: python/cpython#77377

    The simplest pure python repro:

    import multiprocessing as mp
    import faulthandler
    
    # Just to print the segfault in the child
    faulthandler.enable()
    
    def _mp_fn(barrier):
        barrier.wait()
    
    if __name__ == '__main__':
        barrier = mp.get_context("fork").Barrier(1)
        p = mp.get_context("spawn").Process(target=_mp_fn, args=(barrier,))
        p.start()
        p.join()
  11. albanD commented on Jul 25, 2023

    @albanD
    Collaborator

    @pritamdamania87 so the answer is you should NOT mix different multiprocessing contexts and you should pass the right context to the Dataloader if you want to use a special one!
    This is a limitation of CPython that doesn't gracefully handle these mixed context data (see linked issue above).

    Is that a satisfiable answer?

  12. pritamdamania87 commented on Jul 25, 2023

    @pritamdamania87
    ContributorAuthor

    @albanD Thanks a lot for looking into this and yes that is what we are doing currently.

  13. albanD commented on Jul 26, 2023

    @albanD
    Collaborator

    Sent a PR to CPython to make it a nicer error: python/cpython#107275
    But your code will still have to be updated to be using consistent context.

  14. SuperSecureHuman commented on Aug 21, 2023

    @SuperSecureHuman

    Similar error. I am using PyTorch lightning, the error traces back to a similar style.

    Here is a relatable case #4969 (comment)

    I am having Python in a different mount than the data. But it's needed for me to do so, because of the amount of data I have.

    As far as reproducing this error - it occurs really randomly - Some times in 3rd epoch, sometimes in 8 and so on.

    The fact that the same issue is persistent past 5 years is mind twisting

    
    Traceback (most recent call last):
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1133, in _try_get_data
         data = self._data_queue.get(timeout=timeout)
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/queues.py", line 122, in get
         return _ForkingPickler.loads(res)
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/multiprocessing/reductions.py", line 307, in rebuild_storage_fd
         fd = df.detach()
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/resource_sharer.py", line 57, in detach
         with _resource_sharer.get_connection(self._id) as conn:
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/resource_sharer.py", line 86, in get_connection
         c = Client(address, authkey=process.current_process().authkey)
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/connection.py", line 508, in Client
         answer_challenge(c, authkey)
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/connection.py", line 752, in answer_challenge
         message = connection.recv_bytes(256)         # reject large message
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/connection.py", line 216, in recv_bytes
         buf = self._recv_bytes(maxlength)
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/connection.py", line 414, in _recv_bytes
         buf = self._recv(4)
       File "/home/corelabs/miniconda3/lib/python3.10/multiprocessing/connection.py", line 379, in _recv
         chunk = read(handle, remaining)
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
         _error_if_any_worker_fails()
     RuntimeError: DataLoader worker (pid 10540) is killed by signal: Segmentation fault.
     The above exception was the direct cause of the following exception:
     Traceback (most recent call last):
       File "/home/corelabs/datastore/supersecurehuman/Malware_Header_Proj/pl_trainer/resnet18/train.py", line 63, in <module>
         trainer.fit(resnet, train_dataloaders=train_loader, val_dataloaders=val_loader)
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 520, in fit
         call._call_and_handle_interrupt(
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/trainer/call.py", line 44, in _call_and_handle_interrupt
         return trainer_fn(*args, **kwargs)
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 559, in _fit_impl
         self._run(model, ckpt_path=ckpt_path)
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 935, in _run
         results = self._run_stage()
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 978, in _run_stage
         self.fit_loop.run()
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py", line 201, in run
         self.advance()
       File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py", line 354, in advance
        self.epoch_loop.run(self._data_fetcher)
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/loops/training_epoch_loop.py", line 133, in run
        self.advance(data_fetcher)
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/loops/training_epoch_loop.py", line 189, in advance
        batch = next(data_fetcher)
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/loops/fetchers.py", line 136, in __next__
        self._fetch_next_batch(self.dataloader_iter)
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/loops/fetchers.py", line 150, in _fetch_next_batch
        batch = next(iterator)
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/utilities/combined_loader.py", line 264, in __next__
        out = next(self._iterator)
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/lightning/pytorch/utilities/combined_loader.py", line 52, in __next__
        out[i] = next(self.iterators[i])
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 634, in __next__
        data = self._next_data()
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1329, in _next_data
        idx, data = self._get_data()
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1295, in _get_data
        success, data = self._try_get_data()
      File "/home/corelabs/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1146, in _try_get_data
        raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) from e
    RuntimeError: DataLoader worker (pid(s) 10540) exited unexpectedly
    
    
  15. SuperSecureHuman commented on Aug 21, 2023

    @SuperSecureHuman

    Update - Same error without setting num_workers

    image

  16. albanD commented on Aug 21, 2023

    @albanD
    Collaborator

    Did you pass in the multiprocessing context as an input to the dataloader as discussed above?

    Also if the version without multiprocessing segfaults, that means that the segfault is not the same.
    Can you use gdb to get a stack trace for the segfault in the case where num_workers=0?

  17. SuperSecureHuman commented on Aug 22, 2023

    @SuperSecureHuman

    Hey!

    No I did not pass multiprocessing context to the dataloader.

    I choose to comment here, because - this was the recent issue that was most similar to the one I was getting.

    I would need some time to get the stack trace back, since this error is on a remote machine, and the error occurs at random.

    I will pipe everything to a file, and attach it here, once I am done with the stack trace

  18. SuperSecureHuman commented on Aug 22, 2023

    @SuperSecureHuman

    Dataloader - return DataLoader(self.train_dataset, batch_size=self.batch_size, shuffle=True, num_workers=0)

    The "data" part of dataloader is perfectly fine - It trains for a few epochs. So it's mostly not the way how data is being processed.

    Update - Ran with num_workers=0, and the error doesn't come up now. As I told, its completely random in my case.

    I will run all my runs with gdb, and log the outputs to a file, so that I will share them once I hit the seg fault

  19. SuperSecureHuman commented on Aug 22, 2023

    @SuperSecureHuman

    I have trimmed the output to whereever there was some special output from GDB

    Best part is that, only when using multiprocessing, we get to know that error's stack trace (which is from dataloader)

    When not using multiple workers, it just says seg fault

    image

    /usr/local/src/conda/python-3.10.10/Include/object.h:146 --> this is non existent, not sure why its looking here.

    GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
    Copyright (C) 2022 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    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:
    <https://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
        <http://www.gnu.org/software/gdb/documentation/>.
    
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from python...
    Starting program: /home/corelabs/miniconda3/bin/python mixed.py
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    [New Thread 0x7fff5bdff640 (LWP 60395)]
    [New Thread 0x7fff5b5fe640 (LWP 60396)]
    [New Thread 0x7fff58dfd640 (LWP 60397)]
    [New Thread 0x7fff565fc640 (LWP 60398)]
    [New Thread 0x7fff53dfb640 (LWP 60399)]
    [New Thread 0x7fff515fa640 (LWP 60400)]
    [New Thread 0x7fff4edf9640 (LWP 60401)]
    [New Thread 0x7fff4c5f8640 (LWP 60402)]
    [New Thread 0x7fff49df7640 (LWP 60403)]
    [New Thread 0x7fff475f6640 (LWP 60404)]
    [New Thread 0x7fff44df5640 (LWP 60405)]
    [New Thread 0x7fff405f4640 (LWP 60406)]
    [New Thread 0x7fff3fdf3640 (LWP 60407)]
    [New Thread 0x7fff3d5f2640 (LWP 60408)]
    [New Thread 0x7fff3adf1640 (LWP 60409)]
    [New Thread 0x7fff385f0640 (LWP 60410)]
    [New Thread 0x7fff35def640 (LWP 60411)]
    [New Thread 0x7fff315ee640 (LWP 60412)]
    [New Thread 0x7fff30ded640 (LWP 60413)]
    [New Thread 0x7fff2c5ec640 (LWP 60414)]
    [New Thread 0x7fff29deb640 (LWP 60415)]
    [New Thread 0x7fff275ea640 (LWP 60416)]
    [New Thread 0x7fff24de9640 (LWP 60417)]
    [New Thread 0x7fff225e8640 (LWP 60418)]
    [New Thread 0x7fff21de7640 (LWP 60419)]
    [New Thread 0x7fff1d5e6640 (LWP 60420)]
    [New Thread 0x7fff1cde5640 (LWP 60421)]
    [New Thread 0x7fff1a5e4640 (LWP 60422)]
    [New Thread 0x7fff17de3640 (LWP 60423)]
    [New Thread 0x7fff155e2640 (LWP 60424)]
    [New Thread 0x7fff12de1640 (LWP 60425)]
    [Detaching after vfork from child process 60431]
    [Detaching after vfork from child process 60432]
    [Detaching after vfork from child process 60433]
    [New Thread 0x7fff001ff640 (LWP 60438)]
    [New Thread 0x7ffeebbff640 (LWP 60449)]
    [New Thread 0x7ffee93fe640 (LWP 60450)]
    [New Thread 0x7ffee8bfd640 (LWP 60451)]
    [New Thread 0x7ffee63fc640 (LWP 60452)]
    [New Thread 0x7ffee3bfb640 (LWP 60453)]
    [New Thread 0x7ffedf3fa640 (LWP 60454)]
    [New Thread 0x7ffedebf9640 (LWP 60455)]
    [New Thread 0x7ffedc3f8640 (LWP 60456)]
    [New Thread 0x7ffed9bf7640 (LWP 60457)]
    [New Thread 0x7ffed73f6640 (LWP 60458)]
    [New Thread 0x7ffed4bf5640 (LWP 60459)]
    [New Thread 0x7ffed03f4640 (LWP 60460)]
    [New Thread 0x7ffecfbf3640 (LWP 60461)]
    [New Thread 0x7ffecd3f2640 (LWP 60462)]
    [New Thread 0x7ffec8bf1640 (LWP 60463)]
    [New Thread 0x7ffec83f0640 (LWP 60464)]
    [New Thread 0x7ffec5bef640 (LWP 60465)]
    [New Thread 0x7ffec13ee640 (LWP 60466)]
    [New Thread 0x7ffec0bed640 (LWP 60467)]
    [New Thread 0x7ffebc3ec640 (LWP 60468)]
    [New Thread 0x7ffebbbeb640 (LWP 60469)]
    [New Thread 0x7ffeb93ea640 (LWP 60470)]
    [New Thread 0x7ffeb6be9640 (LWP 60471)]
    [New Thread 0x7ffeb43e8640 (LWP 60472)]
    [New Thread 0x7ffeb1be7640 (LWP 60473)]
    [New Thread 0x7ffeaf3e6640 (LWP 60474)]
    [New Thread 0x7ffeaabe5640 (LWP 60475)]
    [New Thread 0x7ffeaa3e4640 (LWP 60476)]
    [New Thread 0x7ffea5be3640 (LWP 60477)]
    [New Thread 0x7ffea53e2640 (LWP 60478)]
    [New Thread 0x7ffea2be1640 (LWP 60479)]
    [Detaching after vfork from child process 60487]
    [Detaching after vfork from child process 60488]
    [Detaching after vfork from child process 60489]
    [New Thread 0x7ffe9b84a640 (LWP 60528)]
    [Thread 0x7ffe9b84a640 (LWP 60528) exited]
    [New Thread 0x7ffe9b84a640 (LWP 60536)]
    [New Thread 0x7ffe9b049640 (LWP 60570)]
    [New Thread 0x7ffe9a848640 (LWP 60571)]
    [New Thread 0x7ffe8b3ff640 (LWP 60577)]
    [New Thread 0x7ffe8abfe640 (LWP 60578)]
    [New Thread 0x7ffe8a3fd640 (LWP 60579)]
    [New Thread 0x7ffe89bfc640 (LWP 60580)]
    [New Thread 0x7ffe893fb640 (LWP 60581)]
    [New Thread 0x7ffe88bfa640 (LWP 60582)]
    [New Thread 0x7ffe883f9640 (LWP 60583)]
    [New Thread 0x7ffe87bf8640 (LWP 60584)]
    [New Thread 0x7ffe873f7640 (LWP 60585)]
    [New Thread 0x7ffe86bf6640 (LWP 60586)]
    [New Thread 0x7ffe863f5640 (LWP 60587)]
    [New Thread 0x7ffe85bf4640 (LWP 60588)]
    [New Thread 0x7ffe853f3640 (LWP 60589)]
    [New Thread 0x7ffe84bf2640 (LWP 60590)]
    [New Thread 0x7ffe843f1640 (LWP 60591)]
    [New Thread 0x7ffe80a1a640 (LWP 60600)]
    [New Thread 0x7ffe75fff640 (LWP 60601)]
    [New Thread 0x7ffe7559d640 (LWP 60602)]
    [New Thread 0x7ffe82bff640 (LWP 60603)]
    Epoch 16:  88%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Ž        | 708/800 [02:24<00:18,  4.89it/s, v_num=9paa, val_loss=0.0643, val_acc=0.980, val_f1=0.980, val_recall=0.980, val_precision=0.980, train_loss=0.0409, train_acc=0.988]
    Epoch 16:  88%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Ž        | 708/800 [02:24<00:18,  4.89it/s, v_num=9paa, val_loss=0.0643, val_acc=0.980, val_f1=0.980, val_recall=0.980, val_precision=0.980, train_loss=0.0409, train_acc=0.988]
    Thread 1 "python" received signal SIGSEGV, Segmentation fault.
    PyDict_GetItem (op=0x7ffff71ed480, key=0x0) at /usr/local/src/conda/python-3.10.10/Include/object.h:146
    οΏ½[?2004h(gdb) exit
    οΏ½[?2004l
    οΏ½[?2004hA debugging session is active.
    
    	Inferior 1 [process 60373] will be killed.
    
    Quit anyway? (y or n) n
    οΏ½[?2004l
    οΏ½[?2004h(gdb) exit
    οΏ½[?2004l
    οΏ½[?2004hA debugging session is active.
    
    	Inferior 1 [process 60373] will be killed.
    
    Quit anyway? (y or n) y
    οΏ½[?2004l
    
    
  20. albanD commented on Aug 22, 2023

    @albanD
    Collaborator

    I'm very confused by what you say: "Ran with num_workers=0, and the error doesn't come up now." and "When not using multiple workers, it just says seg fault".

    In any case, sounds like this is not this issue. I would suggest you ask on the forum to get help debugging your code: https://discuss.pytorch.org/

  21. SuperSecureHuman commented on Aug 22, 2023

    @SuperSecureHuman

    When I mentioned this - Ran with num_workers=0 that was earlier, when I thought the issue randomly stopped occurring.

    The 2nd message I sent - where I mentioned When not using multiple workers, it just says seg fault I actually meant num_workers=0

    Sorry for the wrong way of telling whatever I want to tell.

    In summary - The error still occurs - even when setting workers to 0.

    When setting the value of workers more than 1, the PyTorch error trace points back to dataloader.

    Again, really sorry if I confused you earlier.

  22. albanD commented on Aug 22, 2023

    @albanD
    Collaborator

    In summary - The error still occurs - even when setting workers to 0.

    This means that the dataloader is not the root cause and your issue doesn't match this one. Please post the details on the forum to discuss this more.

  23. albanD commented on Aug 23, 2023

    @albanD
    Collaborator

    This is now fixed in CPython and will nicely raise an error on 3.11+ (once the bugfix patch is released)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    high prioritymodule: multiprocessingRelated to torch.multiprocessingtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions