DataLoader process gets killed while creating batch

I have an Image databunch generated using the following code

data = (SegmentationItemList.from_folder(image_dir)
        .label_from_func(get_y_fn, classes=codes)
        .transform(get_transforms(), tfm_y=True, size=256)
        .databunch(bs=9, path=data_loc)

When I try to get a batch from this DataBunch using data.one_batch(), I get a the following RuntimeError

RuntimeError: DataLoader worker (pid 2813) is killed by signal: Unknown signal: 0. 
During handling of the above exception, another exception occurred:
RuntimeError: DataLoader worker (pid(s) 2813) exited unexpectedly

I thought this was because the process was using too much memory. So, I reduced the image size to 128 and batch size to 4 but still faced the same problem.
How do I fix this?

1 Like

You have some problem with your data and PyTorch can’t load a batch for some reason. You should pass num_workers=0 in your call to databunch to get a clearer error message.


Thank you. Setting num_workers=0 worked.

1 Like