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.

[Bug] VITS recipe breaks with "local variable 'outputs' referenced before assignment"

See original GitHub issue

Describe the bug When I try to train VITS in any way, e.g. with the recipe, it crashes with local variable 'outputs' referenced before assignment.

To Reproduce Steps to reproduce the behavior:

  • Make a directory runs2
  • Copy the VITS recipe recipes/ljspeech/vits_tts/train_vits.py into there
  • Place LJSpeech dataset into there
  • Run it: CUDA_VISIBLE_DEVICES=0 python runs2/train_vits.py
  • Wait for the first > EVALUATION
  • It immediately crashes

Expected behavior It doesn’t crash.

Environment (please complete the following information):

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.04
  • PyTorch or TensorFlow version (use command below): PyTorch 1.9.0 w/ CUDA 11.1
  • Python version: 3.7.11
  • CUDA/cuDNN version: 11.1
  • GPU model and memory: RTX 3090 24GB
  • Exact command to reproduce: See β€œTo Reproduce” section.

Additional context

Here’s the last part of the output:

 > DataLoader initialization
 | > Use phonemes: True
   | > phoneme language: en-us
 | > Number of instances : 131
 | > Computing phonemes ...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 131/131 [00:06<00:00, 19.03it/s] | > Max length sequence: 445286
 | > Min length sequence: 69478
 | > Avg length sequence: 288066.8244274809
 | > Num. instances discarded by max-min (max=5000, min=0) seq limits: 131
 | > Batch group size: 0.

 > EVALUATION

Traceback (most recent call last):
  File "/home/fijipants/repo/coqui-0.2.1/TTS/trainer.py", line 911, in fit
    self._fit()
  File "/home/fijipants/repo/coqui-0.2.1/TTS/trainer.py", line 898, in _fit
    self.eval_epoch()
  File "/home/fijipants/repo/coqui-0.2.1/TTS/trainer.py", line 839, in eval_epoch
    figures, audios = self.model.eval_log(self.ap, batch, outputs)
UnboundLocalError: local variable 'outputs' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "runs2/train_vits.py", line 52, in <module>
    trainer.fit()
  File "/home/fijipants/repo/coqui-0.2.1/TTS/trainer.py", line 930, in fit
    remove_experiment_folder(self.output_path)
  File "/home/fijipants/repo/coqui-0.2.1/TTS/utils/generic_utils.py", line 74, in remove_experiment_folder
    print(" ! Run is removed from {}".format(experiment_path))
  File "/home/fijipants/repo/coqui-0.2.1/TTS/trainer.py", line 986, in write
    with open(self.log_file, "a", encoding="utf-8") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/fijipants/repo/coqui-0.2.1/runs2/vits_ljspeech-August-31-2021_11+23PM-5793dca7/trainer_0_log.txt'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lexkorocommented, Sep 2, 2021

you filtered out all of your data with the seq_limits.

 | > Number of instances : 131
 | > Min length sequence: 69478
 | > Avg length sequence: 288066.8244274809
 | > Num. instances discarded by max-min (max=5000, min=0) seq limits: 131

With the latest update the vits recipe uses the length of the audio instead of text for filtering.

1reaction
fijipantscommented, Sep 1, 2021

@erogol Oh no, I’ll try again from scratch and see if I can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3: UnboundLocalError: local variable referenced ...
In your case, Var1 is considered as a local variable, and it's used before being set, thus the error. To solve this problem,...
Read more >
Local Variable Referenced Before Assignment - STechies
The β€œlocal variable referenced before assignment” error occurs when you give reference of a local variable without assigning any value. Example:
Read more >
[SOLVED] Local Variable Referenced Before Assignment
Unboundlocalerror: local variable referenced before assignment is thrown if a variable is assigned before it's bound.
Read more >
Local variable referenced before assignment in Python
The Python UnboundLocalError: Local variable referenced before assignment occurs when we reference a local variable before assigning a valueΒ ...
Read more >
Python local variable referenced before assignment Solution
This error is raised when you try to use a variable before it has been assigned in the local context. In this guide,...
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