jaywalnut310 / vits

VITS: Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech
https://jaywalnut310.github.io/vits-demo/index.html
MIT License
6.53k stars 1.22k forks source link

Sorry I have a Question about RuntimeError #113

Closed mao-mao-yu closed 1 year ago

mao-mao-yu commented 1 year ago
Traceback (most recent call last):
  File "train.py", line 332, in <module>
    main()
  File "train.py", line 67, in main
    mp.spawn(run, nprocs=n_gpus, args=(n_gpus, hps,))
  File "C:\Users\mashi\anaconda3\envs\chat37\lib\site-packages\torch\multiprocessing\spawn.py", line 230, in spawn
    return start_processes(fn, args, nprocs, join, daemon, start_method='spawn')
  File "C:\Users\mashi\anaconda3\envs\chat37\lib\site-packages\torch\multiprocessing\spawn.py", line 188, in start_processes
    while not context.join():
  File "C:\Users\mashi\anaconda3\envs\chat37\lib\site-packages\torch\multiprocessing\spawn.py", line 150, in join
    raise ProcessRaisedException(msg, error_index, failed_process.pid)
torch.multiprocessing.spawn.ProcessRaisedException:

-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "C:\Users\mashi\anaconda3\envs\chat37\lib\site-packages\torch\multiprocessing\spawn.py", line 59, in _wrap
    fn(i, *args)
  File "C:\Users\mashi\PycharmProjects\voice_train\vits\train.py", line 148, in run
    [train_loader, eval_loader], logger, [writer, writer_eval])
  File "C:\Users\mashi\PycharmProjects\voice_train\vits\train.py", line 176, in train_and_evaluate
    (z, z_p, m_p, logs_p, m_q, logs_q) = net_g(x, x_lengths, spec, spec_lengths)
  File "C:\Users\mashi\anaconda3\envs\chat37\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\mashi\anaconda3\envs\chat37\lib\site-packages\torch\nn\parallel\distributed.py", line 692, in forward
    if self.reducer._rebuild_buckets():

RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by (1) passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel; (2) making sure all forward function outputs participate in calculating loss. If you already have done the above two steps, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable).

fzyxh commented 1 year ago

I have the same problem, and I solved it by adding argument below:

in train.py, Line 99:

  # net_g = DDP(net_g, device_ids=[rank])
  net_g = DDP(net_g, device_ids=[rank], find_unused_parameters=True)

Add argument find_unused_parameters=True here might help you.

mao-mao-yu commented 1 year ago

Thank you for your answer. I have solved this problem