当前位置: 首页 > news >正文

RuntimeError: “slow_conv2d_cpu“ not implemented for ‘Half‘

RuntimeError: “slow_conv2d_cpu” not implemented for ‘Half’

在这里插入图片描述

背景

测试语音识别模型whisper时,出现上述错误!!
测试代码如下:

import whispermodel = whisper.load_model("base")
# print(model)# load audio and pad/trim it to fit 30 seconds
mps_path = r"/test/1.mp3"
audio = whisper.load_audio(mps_path)
print("audio:\n", audio)
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()  # fp16=False
result = whisper.decode(model, mel, options)# print the recognized text
print(result.text)

报错原因

将输入数据的类型设置为Half(半精度浮点数,可以加快计算速度),但是Half只有GPU支持,CPU不支持半(Half)精度训练。

解决方法

通过使用 fp16=False,来指定解码选项,顺利解决了这个错误。

options = whisper.DecodingOptions(fp16=False)

网上给出的参考解决办法如下:

  1. 执行代码的命令后添加“- -fp32”
  2. 将use_half=False 或者 将half() 方法 修改为float()
  3. 搜索代码“half”、“16”等字样,找到代码中涉及半精度的代码,进行修改
http://www.lryc.cn/news/189443.html

相关文章:

  • 前端 | 前端工程化
  • 学信息系统项目管理师第4版系列24_整合管理
  • 轻量级虚拟化技术草稿
  • bootz启动 Linux内核过程中涉及的 do_bootm_states 函数
  • springcloud学习笔记(3)-服务管理组件Nacos
  • Insight h2database 更新、读写锁以及事务原理
  • skywalking动态配置[集成nacos/apollo/consul]
  • UniApp创建项目HelloWorld
  • Qt/C++原创推流工具/支持多种流媒体服务/ZLMediaKit/srs/mediamtx等
  • 学习黑马程序员JavaScript总结
  • 浅谈高速公路服务区分布式光伏并网发电
  • MATLAB算法实战应用案例精讲-【图像处理】机器视觉(番外篇)
  • 塑胶材料检测对激光焊机的作用
  • 将Eureka服务注册到Eureka中心
  • 将网站域名访问从http升级到https(腾讯云/阿里云)
  • QT通过TCP协议发送结构体数据
  • C++标准库之numeric
  • 第六章:最新版零基础学习 PYTHON 教程—Python 正则表达式(第二节 - Python 中的正则表达式与示例套装)
  • 【Python】WebUI自动化—Selenium的下载和安装、基本用法、项目实战(16)
  • c++视觉处理---图像重映射
  • 基于YOLO算法的单目相机2D测量(工件尺寸和物体尺寸)
  • Insight h2database 执行计划评估以及 Selectivity
  • [天翼杯 2021]esay_eval - RCE(disabled_function绕过||AS_Redis绕过)+反序列化(大小写wakeup绕过)
  • 基于SSM+Vue的在线作业管理系统的设计与实现
  • Webapck 解决:[webpack-cli] Error: Cannot find module ‘vue-loader/lib/plugin‘ 的问题
  • 使用UiPath和AA构建的解决方案 5. 使用UiPath ReFramework处理采购订单
  • SQL基本语法用例大全
  • MAX17058_MAX17059 STM32 iic 驱动设计
  • 大数据笔记-大数据处理流程
  • wps演示时图片任意位置拖动