【问题标题】:How to use GPU for Fine-tuning HuggingSound custom model如何使用 GPU 微调 HuggingSound 自定义模型
【发布时间】:2023-01-04 15:44:59
【问题描述】:

我想使用此代码Fine-tune我的model

from huggingsound import TrainingArguments, ModelArguments, SpeechRecognitionModel, TokenSet

model = SpeechRecognitionModel("facebook/wav2vec2-large-xlsr-53")
output_dir = "my/finetuned/model/output/dir"

tokens = ["a", "b", ... "y", "z", "'"]
token_set = TokenSet(tokens)

train_data = [
    {"path": "/path/to/sagan.mp3", "transcription": "some text"},
    {"path": "/path/to/asimov.wav", "transcription": "some text"},
]
eval_data = [
    {"path": "/path/to/sagan.mp3", "transcription": "some text"},
    {"path": "/path/to/asimov.wav", "transcription": "some text"},
]


model.finetune(
    output_dir, 
    train_data=train_data, 
    eval_data=eval_data,
    token_set=token_set,
)

它在RAM 上运行,我想使用Colab-GPU 来训练这个模型

【问题讨论】:

    标签: google-colaboratory huggingface-transformers fine-tune


    【解决方案1】:

    我找到了这样做的方法

    import torch
    device = "cuda" if torch.cuda.is_available() else "cpu"
    model = SpeechRecognitionModel("facebook/wav2vec2-large-xlsr-53", device=device)
    

    GPU 上训练的模型

    【讨论】:

      猜你喜欢
      • 2021-10-21
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      • 2022-08-26
      • 2014-03-08
      • 2018-08-21
      • 2014-09-01
      相关资源
      最近更新 更多