Exception: Caught Exception in DataLoader worker process 0

I am a fresh of leaning PyTorch. When try to train the TDNN, I got the fellow error and don’t know how to adress it. Thanks in advance.

File “C:\Users\MGD天真有邪\implement with code\x-vector_pytorch-master\train.py”, line 120, in
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
net = train()
File “C:\Users\MGD天真有邪\implement with code\x-vector_pytorch-master\train.py”, line 73, in train
for i, inputs in enumerate(trainloader , 0):
File “D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py”, line 819, in next
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
Warning, default feature storage mode is now using compression
return self._process_data(data)
File “D:\anaconda3\lib\site-packages\torch\utils\data\dataloader.py”, line 846, in _process_data
data.reraise()
File “D:\anaconda3\lib\site-packages\torch_utils.py”, line 369, in reraise
raise self.exc_type(msg)
Exception: Caught Exception in DataLoader worker process 0.

Could you set num_workers=0, rerun the code again, and post the error message here?
Using the main thread should give a better message.

1 Like

Thank you very much first, i get the reason that my dataLoader is error for my Dataset class error. I‘m sorry for my late reply. Thank you again, if i have new problem and expect your guidance.

hello, I am facing an issue when I am running the ./train.sh command. Error is displaying not file/directory found but my wave is inside the same directory. This is my command
python main/nnet/trainnew.py --gpus 0 --epochs 50 --checkpoint /media/speech70809/Data02/MS_R1_SL2_Wparameter_update_saved_models --batch-size 4 --num-workers 0

How can I solve this error? thank you so much

2021-10-31 07:16:04 [/media/speech70809/Data01/speech_donoiser_new/main/nnet/trainnew.py:87 - INFO ] Arguments in command:
{‘batch_size’: 4,
‘checkpoint’: ‘/media/speech70809/Data02/MS_R1_SL2_Wparameter_update_saved_models’,
‘epochs’: 50,
‘gpus’: ‘0’,
‘num_workers’: 0,
‘resume’: ‘’}
no_impr: 100
patience: 2
start eval
Traceback (most recent call last):
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/trainnew.py”, line 91, in
run(args)
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/trainnew.py”, line 53, in run
trainer.run(train_loader, dev_loader, num_epochs=args.epochs)
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/trainer.py”, line 221, in run
cv = self.eval(dev_loader)
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/trainer.py”, line 208, in eval
for egs in data_loader:
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/dataset.py”, line 143, in iter
for chunks in self.eg_loader:
File “/home/speech70809/anaconda3/envs/speech_denoiser/lib/python3.9/site-packages/torch/utils/data/dataloader.py”, line 521, in next
data = self._next_data()
File “/home/speech70809/anaconda3/envs/speech_denoiser/lib/python3.9/site-packages/torch/utils/data/dataloader.py”, line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File “/home/speech70809/anaconda3/envs/speech_denoiser/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/home/speech70809/anaconda3/envs/speech_denoiser/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/dataset.py”, line 41, in getitem
mix = self.mix[key]
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/audio.py”, line 120, in getitem
return self._load(index)
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/audio.py”, line 138, in _load
samp_rate, samps = read_wav(
File “/media/speech70809/Data01/speech_donoiser_new/main/nnet/libs/audio.py”, line 38, in read_wav
samp_rate, samps_int16 = wf.read(fname)
File “/home/speech70809/anaconda3/envs/speech_denoiser/lib/python3.9/site-packages/scipy/io/wavfile.py”, line 647, in read
fid = open(filename, ‘rb’)
FileNotFoundError: [Errno 2] No such file or directory: ‘/media/lab70809/Data01/speech_donoiser_new/datasets/ner-300hr/cv/mix/BG_20170420_133-JZ_20160301_040_LTL7zFtz8UQ_snr6_fileid_528.wav’

Make sure the file is indeed in this location by running ls on it in a terminal:

~$: ls /media/lab70809/Data01/speech_donoiser_new/datasets/ner-300hr/cv/mix/BG_20170420_133-JZ_20160301_040_LTL7zFtz8UQ_snr6_fileid_528.wav

of this returns valid file information, I would guess that the mount is somehow dropped during the script execution.

ls: cannot access ‘/media/lab70809/Data01/speech_donoiser_new/datasets/ner-300hr/cv/mix/BG_20170420_133-JZ_20160301_040_LTL7zFtz8UQ_snr6_fileid_528.wav’: No such file or directory

after using the ls command it says “cannot access”.
how I can solve this one?

This would mean that the file doesn’t exist and the Dataset raises the error as expected so make sure to load existing files.

I have solved this problem. Thank you so much

Kuldeep - would you mind sharing your solution? I am having intermittent errors of the same type.

Check your dataset path and the other remaining paths.