-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
stft does not consistently check window device #30865
Comments
Ah the error message is indeed confusing. The issue is that your window is still on CPU. |
currently facing the same issue - any fix planned? The same issue seems to exist in torchaudio.transforms.MelSpectrogram |
bump. any news on the issue? the same thing happening with me when |
As of #43886, both calls now raise an error: >>> torch.stft(x, n_fft=512, hop_length=160, win_length=400, window=window).shape
...
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
>>> torch.stft(x, n_fft=400, hop_length=160, win_length=400, window=window).shape
...
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! I believe this is because of the diff here: https://github.com/pytorch/pytorch/pull/43886/files#diff-8189529460e7e7e3cbd932342fd61d76L243-R280. The I'm not sure if the original device-moving behavior was actually intentional though. As far as I'm aware, most PyTorch functions require inputs to be on the same device. The fix from the user's side would be to pass in |
Thanks for the update @peterbell10, sounds like this issue has been fixed.
Right, we don't like to implicitly move tensors from one device to another. Data movement in PyTorch should always be explicit like, as you point out, a user calling |
馃悰 Bug
Consider a situation when applying
torch.stft
to audiox
, which is in CUDA memory. We also have a given tensorwindow
, which is not in CUDA memory yet.When
n_fft
is equal towin_length
, it causesRuntimeError: expected device cuda:0 but got device cpu
.To Reproduce
See my Google Colab notebook:
https://colab.research.google.com/drive/15ZOc5SnFwXsb3-vgIbzdd2roeY6kOV2H
Expected behavior
No error is expected here.
cc @mruberry @peterbell10
The text was updated successfully, but these errors were encountered: