Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ChekeLee opened this issue Oct 20, 2020 · 1 comment

Comments

@ChekeLee
Copy link

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

@jongwook
Copy link
Owner

jongwook commented Oct 20, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants