DataLoader process gets killed while creating batch

(Vishal R) #1

I have an Image databunch generated using the following code

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

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?

0 Likes

#2

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.

0 Likes

(Vishal R) #3

Thank you. Setting num_workers=0 worked.

0 Likes