PlayVoice / whisper-vits-svc

Core Engine of Singing Voice Conversion & Singing Voice Clone
https://huggingface.co/spaces/maxmax20160403/sovits5.0
MIT License
2.57k stars 914 forks source link

ImportError: cannot import name 'consume_prefix_in_state_dict_if_present' from 'torch.nn.modules.utils' (/opt/miniconda3/envs/vc2/lib/python3.8/site-packages/torch/nn/modules/utils.py) #142

Open EricPaul03 opened 8 months ago

EricPaul03 commented 8 months ago

Traceback (most recent call last): File "prepare/preprocess_hubert.py", line 9, in from hubert import hubert_model File "/root/code/so-vits-svc-5.0/hubert/hubert_model.py", line 8, in from torch.nn.modules.utils import consume_prefix_in_state_dict_if_present ImportError: cannot import name 'consume_prefix_in_state_dict_if_present' from 'torch.nn.modules.utils' (/opt/miniconda3/envs/vc2/lib/python3.8/site-packages/torch/nn/modules/utils.py) I use torch1.8.0+cu111, but I cannot find this function in the file. What should I do?

MaxMax2016 commented 8 months ago

https://github.com/PlayVoice/Grad-SVC/blob/20230920-V2-96/hubert/hubert_model.py

def consume_prefix(state_dict, prefix: str) -> None:
    keys = sorted(state_dict.keys())
    for key in keys:
        if key.startswith(prefix):
            newkey = key[len(prefix):]
            state_dict[newkey] = state_dict.pop(key)

def hubert_soft(
        path: str,
) -> HubertSoft:
    r"""HuBERT-Soft from `"A Comparison of Discrete and Soft Speech Units for Improved Voice Conversion"`.
    Args:
        path (str): path of a pretrained model
    """
    hubert = HubertSoft()
    checkpoint = torch.load(path)
    consume_prefix(checkpoint, "module.")
    hubert.load_state_dict(checkpoint)
    hubert.eval()
    return hubert
EricPaul03 commented 8 months ago

Thanks for helping me!!! but unfortunately, when I run the next command "python prepare/preprocess_speaker.py", I randomly get "Aborted (core dump)" and then I failed. Could you give me some suggestions?

MaxMax2016 commented 8 months ago

do you have any dump logs?

EricPaul03 commented 8 months ago

Sorry, I don't have any output logs. Based on my observation, this error occurs at irregular times (and sometimes there may be segment fault errors). I think this may also be a problem with my device?

EricPaul03 commented 8 months ago

"frame #7: + x4f591e (9x7fa3f7a99e in /ot/miniconda3/ervs/yc2/lib/ovthon38/site-packapes/torch/lib/libtorch pvth n.so) frame #8: +0x5037f5 (x7f3f777f5 in /opt/miniconda3/ervs/vc2/lib/python38/site-packapes/torch/lib/libtorch pytho n.so)

frame #21: python() [x5a5bd1 frame #22:python()[0x5a4bdfframe #23:python()[0x45c5387 frame #25:python() [ex44fe8f frame #27:libc start main + xe7 (0x7fea4224cc87 in /lib/x86 64-linux-gnu/libc.so.6) frame #28: python() [x579d3d1 Aborted (core dumped)" Hello , I also encountered this error during the post-processing stage. He provided some information. Could you help me?
EricPaul03 commented 8 months ago

terminate called after throwing an instance of 'c10::Error what(): isTuple()INTERWAASSERT FAILED at "/pvtorch/aten/rc/ATen/core/ivalue inlh":136, olease report a bug to PVTorch,Exnecte Tuple but got String Exception raised from toluple at /pvtorch/aten/src/ATen/core/ivalue inl,:1306 most recent call finst):frame #0: C18:Enror::Error(c1::Sourcelocation, std::string) + 0x42 (0x7f099aed4a22 in /opt/miniconda3/envs/vc2/lib/python3.8/site-packages/torch/lib/libc10.so) frame #1: c18::detail.:torchCheckFail(char const, char const, unsigned int, stdstring const&) + 0x5 (x7f09aed13db in /opt/minicorda3/envs/vc2/lib/pvthon3.8/site-packages/torch/lib/libc10.so)frame #2: c10::detail.:torchlntemnalAssertFail(char const%, char const, unsigned int, char const, std:string const&) + 0x3e (0x7f09:ed18ce in /opt/miniconda3/envs/vc2/lib/pvthon3,8/site-packages/torch/lib/libc10.so)Frame #3: + 0x38d277 (0x7f099ec30277 in /ot/miniconda3/envs/vc2/lib/pvthon3.8/site-packages/torch/lib/libtorch cpu so) frame #4: +0x38de315 (0x7f899ec31315 in /opt/miniconda3/envs/vc2/lib/python3.8/site-packages/torch/lib/libtorch cpu. so) frame #5: torch::iit::SourceRange.:highliphtstd::ostream3) const + 0x36 (x7f09c30a356 in /opt/miniconda3/ervs/vc2/lib/python3.8/sitepackages/torch/lib/libtorch cpu.so)frame #6: torch::jit::ErrorReport::what() cnst + 0x2C5 (0x7f899c2eb15 in /opt/miniconda3/envs/vc2/lib/python3.8/site-packapes/torch/li b/libtorch cpu.so)frame #7: + x4f591e (0x7f8a3f7a99e in /opt/miniconda3/envs/vc2/lib/python3,8/site-packages/torch/lib/libtorch pytho n.so) frame #8: + x50375 (0x7f8a3f7b775 n /opt/miniconda3/envs/vc2/lib/python3,8/site-packages/torch/lib/libtorch pytho n.so)

frame #21: python() [x5a5bd1 frame #22: python() [x5a4bdf frame #23: pvthon() x45c538 frame #25: python() [x44fe8f frame #27: libc start main + 0xe7 (0x7foa4224cc87 in /ib/x86 64-linux-gnu/libc.so.6) frame #28: python() [x579d3d] Aborted (core dumped) A full log, please help me, thank you so much!!!