adefossez / demucs

Code for the paper Hybrid Spectrogram and Waveform Source Separation
MIT License
993 stars 96 forks source link

fix: issue with tensor not being on the right device when using separate_audio_file #6

Closed yocontra closed 6 months ago

yocontra commented 6 months ago

Previously Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same if you had the model on cuda, this should move the tensor to the right place.

CarlGao4 commented 6 months ago

I'm not sure about this issue. Can't reproduce.

yocontra commented 6 months ago

@CarlGao4 Did you test it with the model loaded onto a GPU w/ cuda?

abs_filename = "./some.mp3"

model = Separator(model="htdemucs", device="cuda")
_wav, stems = model.separate_audio_file(abs_filename)
CarlGao4 commented 6 months ago

Yes

CarlGao4 commented 6 months ago

Actually, I disagree with this PR as storing the whole audio in VRAM will probably cause OOM. And you can see in the code:

https://github.com/adefossez/demucs/blob/main/demucs/apply.py#L312

Each chunk will be moved to the target device before separating so model and audio will be on the same device at this time.

I quite can't understand why you are encountering this issue. Please provide your error message and maybe you can try reinstalling this module from this repo?

yocontra commented 6 months ago

Hmm not sure, I'll keep debugging but agree this PR isn't the correct solution since it seems this is already being handled.