haoheliu / voicefixer_main

General Speech Restoration
https://haoheliu.github.io/demopage-voicefixer/
MIT License
272 stars 52 forks source link

Vocoder crash #4

Closed Vadim2S closed 2 years ago

Vadim2S commented 2 years ago

Thanks for you PIP module! However I am get error on machine with 2xGPU. I am use simple code as is (with real file path)

from voicefixer import VoiceFixer voicefixer = VoiceFixer() voicefixer.restore(input="", # input wav file path output="", # output wav file path cuda=False, # whether to use gpu acceleration mode = 0) # You can try out mode 0, 1 to find out the best result

from voicefixer import Vocoder #Universal Speaker Independent Vocoder vocoder = Vocoder(sample_rate=44100) # only support 44100 sample rate vocoder.oracle(fpath="", # input wav file path out_path="") # output wav file path

voicefixer part work OK but vocoder part get following error:

Traceback (most recent call last): File "main.py", line 11, in vocoder.oracle(fpath="/home/MassProcessor/_in/KERR_0012.wav", # input wav file path File "/usr/local/lib/python3.8/dist-packages/voicefixer/vocoder/base.py", line 56, in oracle wav_re = self.model(mel) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, kwargs) File "/usr/local/lib/python3.8/dist-packages/voicefixer/vocoder/model/generator.py", line 95, in forward conditions = self.condnet(conditions) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/container.py", line 139, in forward input = module(input) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, kwargs) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/conv.py", line 298, in forward return self._conv_forward(input, self.weight, self.bias) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/conv.py", line 294, in _conv_forward return F.conv1d(input, weight, bias, self.stride, RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

I am try this code on another machine without GPU and vocoder work perfectly

Update with workaround. Turn off CUDA for vocoder like "export CUDA_DEVICE_AVAILABLE=". Yes, nothing after "="

haoheliu commented 2 years ago

Thank you for pointing out that! I'll check it today.

haoheliu commented 2 years ago

Now the problem should be solved in the 0.0.10 voicefixer version. Please give it a try!

Vadim2S commented 2 years ago

Well... Vocoder work now... But VoiceFixer() broken with same GPU error:

voicefixer.restore(input=str(in_file), # input wav file path

File "/usr/local/lib/python3.8/dist-packages/voicefixer/base.py", line 120, in restore out_np_wav = self.restore_inmem(wav_10k, cuda=cuda, mode=mode, your_vocoder_func=your_vocoder_func) File "/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py", line 28, in decorate_context return func(*args, kwargs) File "/usr/local/lib/python3.8/dist-packages/voicefixer/base.py", line 104, in restore_inmem out = self._model.vocoder(denoised_mel) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/usr/local/lib/python3.8/dist-packages/voicefixer/vocoder/base.py", line 48, in forward wav_re = self.model(mel) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, kwargs) File "/usr/local/lib/python3.8/dist-packages/voicefixer/vocoder/model/generator.py", line 95, in forward conditions = self.condnet(conditions) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/container.py", line 139, in forward input = module(input) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, **kwargs) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/conv.py", line 298, in forward return self._conv_forward(input, self.weight, self.bias) File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/conv.py", line 294, in _conv_forward return F.conv1d(input, weight, bias, self.stride, RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

haoheliu commented 2 years ago

Now I'm sure the bug is fixed. Thanks for the help. You can check out this colab demo: https://colab.research.google.com/drive/1T5T3JANxBbsax4IX5Dtys845gNUBTZF9

Vadim2S commented 2 years ago

Big Thanks! All Ok!