lhotse: Issue using Lhotse in NeMo - RuntimeError: cannot join current thread
Hi there,
I’ve run into trouble using the lhotse dataloader in NeMo. My training script is failing straight away when initially trying to load the first batch for step 1.
I am continuing the pretraining of the NEST-L model with ~9,000 hours of custom Irish unlabelled speech. I am training on a single machine with 80 cores, using 3x RTX 8000 Quadro (48Gb) and 128Gb system ram.
I’m attaching the model config file and the output of a failed training attempt. I’m providing a snippet of the error message below.
Have you come across this before? Do you know why this is happening? I was able to continue the pretraining previously for 4000 steps, but I had to stop the training for a couple of reasons. I can’t seem to get it to train again. I even installed a fresh version of NeMo using docker and the latest build, and it still didn’t work.
Any help at all would be greatly appreciated!
Exception in thread Thread-3 (producer):
Traceback (most recent call last):
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/site-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 744, in producer
cuts = next(self.cuts_iter)
TypeError: 'NoneType' object is not an iterator
Exception ignored in: <function DynamicBucketer.__del__ at 0x7fca87762ef0>
Traceback (most recent call last):
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/site-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 784, in __del__
self._producer_thread.join()
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 1093, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
Exception in thread Thread-3 (producer):
Traceback (most recent call last):
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/site-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 744, in producer
cuts = next(self.cuts_iter)
TypeError: 'NoneType' object is not an iterator
Exception ignored in: <function DynamicBucketer.__del__ at 0x7f52ee126ef0>
Traceback (most recent call last):
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/site-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 784, in __del__
self._producer_thread.join()
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 1093, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
Exception in thread Thread-6 (producer):
Traceback (most recent call last):
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/site-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 744, in producer
cuts = next(self.cuts_iter)
TypeError: 'NoneType' object is not an iterator
Exception ignored in: <function DynamicBucketer.__del__ at 0x7f7128f1ef80>
Traceback (most recent call last):
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/site-packages/lhotse/dataset/sampling/dynamic_bucketing.py", line 784, in __del__
self._producer_thread.join()
File "/home/liam/miniconda3/envs/nemo/lib/python3.10/threading.py", line 1093, in join
raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 19
When using drop_last with concurrent_bucketing, sometimes when the data iterator starts, none of the buckets have enough data. Hence, the StopIteration() is raised outside the producer thread, which forces cuts_iter to None and makes the producer thread error (as in the first error, TypeError: ‘NoneType’ object is not an iterator).
Checking for the alive thread and joining it manually at the end of the iteration will solve the problem. However, the iteration will be forced to stop, and a new iteration will start immediately, and this may repeat many times. In this case, you will have to increase your bucket_buffer_size or manually batch the DynamicBucketer._maybe_wait_for_producer to wait for a larger percentage of buffers utilized.
I have made a pull request to fix the join thread problem at #1487, @pzelasko Would you mind checking this pls? Thanks
Very surprising. Anyhow, glad you figured it out.
There’s not a lot of detail but if I had to guess, this could be CPU OOM. You can verify by monitoring it with some tool like htop or nmon. Decreasing bucket_buffer_size and/or shuffle_buffer_size, or num_workers in the dataloader could help.
Thanks for letting me know. This will help narrow it down. Once I figure out what’s caused the issue I’ll let you know here.
One other person has reported this error but I don’t know yet where it’s coming from. I have a suspicion though. It’s going to be a long-shot, but can you re-try with the following option:
model.train_ds.force_iterable_dataset=True?If it works, you should then also shard your jsonl manifest, ie. split it to smaller manifests and provide
data/noise_ssd_{0..N}.jsonlso that your GPUs don’t have correlated mini-batches with that setting.Another thing you can try is setting
model.train_ds.concurrent_bucketing=False- you’ll lose ~10% of efficiency by disabling it, but if it fixes the issue, it will be useful information for further debugging.