I’m a beginner with deep learning, and I’m using Google Colab to run my code.
(pytorch 1.4.0, touchvision 0.5.0)
I generated my databunch by using these code:
tfms = get_transforms(flip_vert=True, max_lighting=0.1, max_zoom=1.05, max_warp=0.5)
src = (ImageList.from_folder(path=data_folder)
.split_by_rand_pct(0.2)
.label_from_folder())
img_data = (src.transform(tfms, size=128)
.databunch()
.normalize(imagenet_stats))
When I try to run
model = cnn_learner(img_data, models.resnet34, metrics=[accuracy, error_rate])
model.data = img_data
model.fit_one_cycle(3)
I got the RuntimeError: DataLoader worker (pid(s) XXX) exited unexpectedly
RuntimeError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _try_get_data(self, timeout) 760 try: --> 761 data = self._data_queue.get(timeout=timeout) 762 return (True, data) 13 frames RuntimeError: DataLoader worker (pid 303) is killed by signal: Segmentation fault. During handling of the above exception, another exception occurred: RuntimeError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in _try_get_data(self, timeout) 772 if len(failed_workers) > 0: 773 pids_str = ', '.join(str(w.pid) for w in failed_workers) --> 774 raise RuntimeError('DataLoader worker (pid(s) {}) exited unexpectedly'.format(pids_str)) 775 if isinstance(e, queue.Empty): 776 return (False, None) RuntimeError: DataLoader worker (pid(s) 303) exited unexpectedly
I’ve tried to reduce my batch_size, but that didn’t work.
I’ve also searched about this error, and it says I need to use num_workers=0
to solve this problem, but I didn’t use any code about DataLoader method.
How could I solve this problem?