onsets-and-frames icon indicating copy to clipboard operation
onsets-and-frames copied to clipboard

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

Open ChekeLee opened this issue 5 years ago • 1 comments
trafficstars

When running transcribe.py, if I choose the DEFAULT_DEVICE='cpu', this will raise the error: RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

File "export.py", line 44, in transcribe mel = melspectrogram(audio.reshape(-1, audio.shape[-1])[:, :-1]).transpose(-1, -2) File "/home/ryusinka/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/ryusinka/cli/pytorch/onsets-and-frames/onsets_and_frames/mel.py", line 93, in forward magnitudes, phases = self.stft(y) File "/home/ryusinka/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/home/ryusinka/cli/pytorch/onsets-and-frames/onsets_and_frames/mel.py", line 59, in forward padding=0) RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

ChekeLee avatar Oct 20 '20 01:10 ChekeLee

I don't know about export.py, but can you try using map_location="cpu" (or map_location=DEFAULT_DEVICE) wherever you're loading the model with torch.load? Basically the input and the model should be on the same device.

jongwook avatar Oct 20 '20 19:10 jongwook