reallymemorable
reallymemorable

Reputation: 1024

"RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'"

I am using OpenAI's new Whisper model for STT, and I get RuntimeError: "slow_conv2d_cpu" not implemented for 'Half' when I try to run it.

Not sure

Here is the full error:

Traceback (most recent call last):
  File "/Users/reallymemorable/git/fp-stt/2-stt.py", line 20, in <module>
    result = whisper.decode(model, mel, options)
  File "/opt/homebrew/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/whisper/decoding.py", line 705, in decode
    result = DecodingTask(model, options).run(mel)
  File "/opt/homebrew/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/whisper/decoding.py", line 621, in run
    audio_features: Tensor = self._get_audio_features(mel)  # encoder forward pass
  File "/opt/homebrew/lib/python3.10/site-packages/whisper/decoding.py", line 565, in _get_audio_features
    audio_features = self.model.encoder(mel)
  File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/whisper/model.py", line 148, in forward
    x = F.gelu(self.conv1(x))
  File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 313, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/opt/homebrew/lib/python3.10/site-packages/whisper/model.py", line 43, in _conv_forward
    return super()._conv_forward(
  File "/opt/homebrew/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 309, in _conv_forward
    return F.conv1d(input, weight, bias, self.stride,
RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'

Here is my code, though I don't think the issue is here:

import whisper

model = whisper.load_model("base")

# load audio and pad/trim it to fit 30 seconds
audio = whisper.load_audio("speech-to-text-sample.wav")
audio = whisper.pad_or_trim(audio)

# make log-Mel spectrogram and move to the same device as the model
mel = whisper.log_mel_spectrogram(audio).to(model.device)

# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}")

# decode the audio
options = whisper.DecodingOptions()
result = whisper.decode(model, mel, options)

# print the recognized text
print(result.text)

How am I supposed to handle a wrong datatype error in a dependency?

Upvotes: 7

Views: 20893

Answers (2)

Bill Zhang
Bill Zhang

Reputation: 201

By specifying decoding option with ftp16 false ,it will fix this error

options = whisper.DecodingOptions(fp16 = False)

Upvotes: 20

MD DIDARUL ISLAM
MD DIDARUL ISLAM

Reputation: 79

Vikram, Half is not supported by CPU, only CUDA.

Upvotes: 7

Related Questions