question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run train.py meets ValueError: `Dataloader` returned 0 length.

See original GitHub issue

Hello!

I am studying the recipe of /asteroid-master/egs/dns_challenge/ and trying to run it for practice. But I met error and I failed to train the model. I run it in my laptop in Linux, I installed pytorch_lightning version 0.9.0 from PyPI. But when I run /asteroid-master/egs/dns_challenge/baseline/run.sh at Stage 3 : Train, it will throw error at pytorch_lightning. The error is as shown below. Train_error_log.txt For more detail please find the attached Train_error_log.txt.


Traceback (most recent call last): File “train.py”, line 121, in <module> main(arg_dic) File “train.py”, line 94, in main trainer.fit(system) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/states.py”, line 48, in wrapped_fn result = fn(self, *args, **kwargs) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/trainer.py”, line 1084, in fit results = self.accelerator_backend.train(model) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/accelerators/cpu_backend.py”, line 39, in train results = self.trainer.run_pretrain_routine(model) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/trainer.py”, line 1224, in run_pretrain_routine self._run_sanity_check(ref_model, model) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/trainer.py”, line 1249, in _run_sanity_check self.reset_val_dataloader(ref_model) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/data_loading.py”, line 337, in reset_val_dataloader self.num_val_batches, self.val_dataloaders = self._reset_eval_dataloader(model, ‘val’) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/data_loading.py”, line 299, in _reset_eval_dataloader num_batches = len(dataloader) if _has_len(dataloader) else float(‘inf’) File “/home/elen/anaconda3/lib/python3.8/site-packages/pytorch_lightning-0.9.1rc4-py3.8.egg/pytorch_lightning/trainer/data_loading.py”, line 70, in _has_len raise ValueError(‘Dataloader returned 0 length.’ ValueError: Dataloader returned 0 length. Please make sure that your Dataloader at least returns 1 batch


I have successfully run it for Stage 1 and 2, and the file_infos.json already created at location ./data. I don’t know what cause this Dataloader to return 0 length. Can you help me to point out what maybe the cause? How can I solve this problem? Thanks in advance!

Best Regards, Elen

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
elenzhengcommented, Oct 7, 2020

I downloaded the default master Branch code just last week. From the Changelog I found its version is [0.3.3] - 2020-08-25. Now after removing the argument ‘train’ from common_step() in the code of /asteroid/engine/system.py, I can successfully run the Stage 3 to train the model.

0reactions
mparientecommented, Oct 7, 2020
  • Because you don’t have many examples.
  • What is your asteroid version?

Please, try debugging before posting the issue, if you solve your problems, you’ll be better after it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: `Dataloader` returned 0 length. Please make sure ...
But when i use pl data module to fit train model, i got dataloader returned 0 length error. import os from typing import...
Read more >
ValueError: `Dataloader` returned 0 length ... - PyTorch Forums
I am trying to train on a sample number of examples, for quick testing. I do an 80/10/10 train/val/test split. I am using...
Read more >
too many values to unpack (expected 2)', upon training a Bert ...
Huggingface Transformers returning 'ValueError: too many values to unpack (expected 2)', upon training a Bert binary classification model.
Read more >
1.2.8 PDF - PyTorch Lightning Documentation
Lightning just needs a DataLoader for the train/val/test splits. ... return torch.relu(self.l1(x.view(x.size(0), -1))).
Read more >
Source code for transformers.trainer - Hugging Face
**is_in_train** -- Whether or not a model is currently running ``train`` (e.g. ... if len(args.sharded_ddp) > 0: if args.deepspeed: raise ValueError( "Using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found