From f68057001688ae75e59c168019850bc0f2a5e742 Mon Sep 17 00:00:00 2001 From: Michael Monashev Date: Mon, 17 Oct 2022 21:38:20 +0300 Subject: [PATCH] Fix bug (#305) Fix bug: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper__index_select) --- whisper/audio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whisper/audio.py b/whisper/audio.py index a6074e8..a3d8a13 100644 --- a/whisper/audio.py +++ b/whisper/audio.py @@ -55,7 +55,7 @@ def pad_or_trim(array, length: int = N_SAMPLES, *, axis: int = -1): """ if torch.is_tensor(array): if array.shape[axis] > length: - array = array.index_select(dim=axis, index=torch.arange(length)) + array = array.index_select(dim=axis, index=torch.arange(length, device=array.device)) if array.shape[axis] < length: pad_widths = [(0, 0)] * array.ndim