whisper在不同 GPU 的性能基准测试

        

做了一些实验来查看不同 GPU 上转录的时间成本。结果可能有助于您选择购买或租用哪种类型的 GPU。

  • 环境:Pytorch 1.13 CUDA 11.6 Ubuntu 18.04
  • 数据集:LJSpeech 从 LJ001-0001.wav 到 LJ001-0150.wav 总长度为 971.26 秒
图形处理器中等 FP16中等 FP32大型 FP16大型 FP32实际时间成本
2080Ti148.18秒219.39秒255.30秒448.24 秒3.7x
3080Ti109.24秒107.81秒172.35秒186.32 秒1.6倍
3090145.53秒122.58秒214.87秒186.12秒1.6倍
409099.60秒79.99秒149.03秒120.05秒1x
V100203.25秒174.18秒284.62 秒253.42秒2.1x
A4000135.99秒128.12秒205.21 秒214.69秒1.8x
A5000143.97秒124.50秒205.43秒198.11秒1.7倍
A6000139.25秒115.63秒194.95秒175.97秒1.5倍
A100 PCIE 40G133.01 秒113.94秒196.19秒175.62秒1.5倍
A100 SXM4 40G123.66秒105.85秒172.36秒162.67秒1.4x

代码

import torch
import time
import whisper
import os

device = torch.device('cuda')
model_list = ['medium', 'large-v2']
fp16_bool = [True, False]
path = './benchmark/'
file_list = os.listdir(path)
for i in model_list:
    for k in fp16_bool:
        model = whisper.load_model(name=i, device=device)
        duration_sum = 0
        for idx, j in enumerate(file_list):
            audio = whisper.load_audio(path + j, sr=16000)
            start = time.time()
            result = model.transcribe(audio, language='en', task='transcribe', fp16=k)
            end = time.time()
            duration_sum = duration_sum + end - start
        print("{} model with fp16 {} costs {:.2f}s".format(i, k, duration_sum))
        del model

 其他测试结果

问:

我也想买 4070,但担心 12GB 是否适合 Large-v3 型号。

答:

        我认为 10GB 卡对于 large-v3 型号来说已经足够了。我购买了 3080 10G 卡,它运行 large-v3 型号就很好了。

答 2 

购买 4 块 RTX 4070 后,我们进行了一些基准测试,您确实对此非常满意。不同 GPU 之间在 Whisper 转录方面的性能差异似乎与您在光栅化性能方面看到的差异非常相似。我们将 T4 与 RTX 4070 和 RTX 4060 Ti 进行了测试,并得出结论:RTX 4070 具有最佳的性价比。

Macbook Pro 14 M2 Max

配备 32GB 内存的 Macbook Pro 14 M2 Max 得到以下结果:
配备 fp32 的中型模型耗时 546.83 秒,
配备 fp32 的大型 v2 模型耗时 904.46 秒,耗时
7.537 倍

我使用免费层硬件对 Huggingface 空间进行了基准测试:

Hugging Face Space Free Tier 2 vCPUs 16GBs ram
tiny.en model with fp16 False costs 430.07s
base.en model with fp16 False costs 563.06s
small.en model with fp16 False costs 1822.23s
medium model with fp16 False costs 4142.89s
large-v2 model with fp16 False costs 7335.92s

以及 I9 13900K:

NVIDIA GeForce RTX 3090
Python 3.11.4 (main, Jul  5 2023, 13:45:01) [GCC 11.2.0]
Torch 2.1.0+cu121
Whisper 20230918
tiny.en model with fp16 True costs 10.22s
tiny.en model with fp16 False costs 5.65s
base.en model with fp16 True costs 9.75s
base.en model with fp16 False costs 8.06s
medium.en model with fp16 True costs 44.88s
medium.en model with fp16 False costs 43.01s
large-v2 model with fp16 True costs 75.89s
large-v2 model with fp16 False costs 66.34s

以及同款 RTX 3090 的低调版本,以供比较:

NVIDIA GeForce RTX 3090
Python 3.11.4 (main, Jul  5 2023, 13:45:01) [GCC 11.2.0]
Torch 2.1.0+cu121
Whisper 20230918
tiny.en model with fp16 True costs 10.22s
tiny.en model with fp16 False costs 5.65s
base.en model with fp16 True costs 9.75s
base.en model with fp16 False costs 8.06s
medium.en model with fp16 True costs 44.88s
medium.en model with fp16 False costs 43.01s
large-v2 model with fp16 True costs 75.89s
large-v2 model with fp16 False costs 66.34s

测试代码

import gradio as gr
import torch
import time
import whisper
import os, sys

def bench(device_name):
    if device_name=="":
        device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    else:
        device = torch.device(device_name)
    string = torch.cuda.get_device_name(0)
    string += "\nPython " + sys.version
    string += "\nTorch " + torch.__version__
    string += "\nWhisper " + whisper.__version__ + "\n"
    print(string)
    model_list = ['tiny.en', 'base.en', 'medium.en', 'large-v2']
    fp16_bool = [True, False]
    path = 'benchmark/'
    file_list = os.listdir(path)
    for i in model_list:
        for k in fp16_bool:
            model = whisper.load_model(name=i, device=device)
            duration_sum = 0
            for idx, j in enumerate(file_list):
                audio = whisper.load_audio(path + j, sr=16000)
                start = time.time()
                result = model.transcribe(audio, language='en', task='transcribe', fp16=k)
                end = time.time()
                duration_sum = duration_sum + end - start
            print("{} model with fp16 {} costs {:.2f}s".format(i, k, duration_sum))
            string += "{} model with fp16 {} costs {:.2f}s".format(i, k, duration_sum) + "\n"
            del model
    return string
    
iface = gr.Interface(fn=bench, inputs="text", outputs="text")
iface.launch()

测试单位(PPM 每分钟处理音频/录音秒数)

RTX 4070 Super 12GBDebian 12.5 上的 Docker(裸机)17,6027,9119,11两个文件,每个文件运行四次
RTX 4070 Super 12GBWindows WSL2 上的 Podman16,8541,3824,10两个文件,每个文件运行七次
RTX 4060ti 16GBWindows WSL2 上的 Podman16,2620,7618,01两个文件,每个文件运行五次

 CPU 的情况

CPU 型号环境最小 PpM最大 PpM平均每分钟流量评论
Ryzen 7 5700G @ 3.80 GHz,8 核Windows WSL2 上的 Podman157,89214,29176,47两个文件,每个文件运行三次
i7-6700K @ 4.00 GHz,4 核Windows WSL2 上的 Podman171,43285,71两个文件,每个文件运行两次
i5-4460 @ 3.2 GHz,4 核(kein HT)Debian 12.5 上的 Docker(裸机)142,86240两个文件,各运行一次
Xeon Gold 5415+ @ 2,90 GHz,4 个 vCoreHyper-V 主机上的 Debian VM 上的 Docker71,43272,73130,43
Xeon E5-2620 v3 @ 2.40 GHz,4 个 vCoreHyper-V 主机上的 Debian VM 上的 Docker200240珠宝

另外的对比图

看来 RTX 4070 性价比比较好,待我买来了RTX4070 super 后再报告结果 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值