Skip to content

mac m1芯片下打开output_timestamp 内存溢出 #218

@zhuchao941

Description

@zhuchao941

Notice: In order to resolve issues more efficiently, please raise issue following the template.
(注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)

🐛 Bug

mps with output_timestamp=True cause oom

 File "/Users/zhuzhuchao/PycharmProjects/FunASR/funasr/models/sense_voice/model.py", line 936, in inference
    align = ctc_forced_align(
            ^^^^^^^^^^^^^^^^^
  File "/Users/zhuzhuchao/PycharmProjects/FunASR/funasr/models/sense_voice/utils/ctc_alignment.py", line 53, in ctc_forced_align
    best_score[:, padding_num:] = log_probs[:, t].gather(-1, _t_a_r_g_e_t_s_) + prev_max_value
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
RuntimeError: MPS backend out of memory (MPS allocated: 1.90 GB, other allocations: 81.94 GB, max allowed: 81.60 GB). Tried to allocate 256 bytes on private pool. Use PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable upper limit for memory allocations (may cause system failure).

To Reproduce

run with macbook m1 cpu

from funasr import AutoModel
from funasr.utils.postprocess_utils import rich_transcription_postprocess

model_dir = "iic/SenseVoiceSmall"

model = AutoModel(
    model=model_dir,
    vad_model="fsmn-vad",
    vad_kwargs={"max_single_segment_time": 30000},
    device="mps",
)

# en
res = model.generate(
    input=f"/Users/zhuzhuchao/Downloads/yuyin/av2/1.wav",
    # input=f"{model.model_path}/example/zh.mp3",
    cache={},
    language="auto",  # "zn", "en", "yue", "ja", "ko", "nospeech"
    use_itn=True,
    batch_size_s=60,
    merge_vad=False,
    # merge_vad=True,  #
    # merge_length_s=15,
    ban_emo_unk=True,
    output_timestamp=True
)
text = rich_transcription_postprocess(res[0]["text"])
print(text)
with open("log-sence.txt", "w") as f:
    f.write(str(res))

Environment

  • OS (e.g., Linux):MacOS 13.2.1
  • FunASR Version (e.g., 1.0.0):1.2.6
  • ModelScope Version (e.g., 1.11.0):
  • PyTorch Version (e.g., 2.0.0):
  • How you installed funasr (pip, source):
  • Python version:
  • GPU (e.g., V100M32)
  • CUDA/cuDNN version (e.g., cuda11.7):
  • Docker version (e.g., funasr-runtime-sdk-cpu-0.4.1)
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions