Artrajz / vits-simple-api

A simple VITS HTTP API, developed by extending Moegoe with additional features.
GNU Affero General Public License v3.0
822 stars 121 forks source link

加载模型出错 #174

Closed jinghuashang closed 3 months ago

jinghuashang commented 3 months ago

使用docker部署,环境为ubuntu 24

在 admin 选择模型加载后无反应,查询日志如下

2024-07-27 21:47:03 [INFO] Loading model model_path: model1/604_epochs.pth config_path: model1/config.json [in views.load_model:74]
[2024-07-27 21:49:04 +0800] [1] [CRITICAL] WORKER TIMEOUT (pid:27)
[2024-07-27 21:49:05 +0800] [1] [ERROR] Worker (pid:27) was sent SIGKILL! Perhaps out of memory?
[2024-07-27 21:49:05 +0800] [28] [INFO] Booting worker with pid: 28

在此之前还有报错,不知道是不是影响了的

2024-07-27 21:45:22 [INFO] Loading failed. PytorchStreamReader failed reading zip archive: failed finding central directory [in ModelManager.load_model:341]
2024-07-27 21:45:22 [ERROR] Traceback (most recent call last):
  File "/app/manager/ModelManager.py", line 322, in load_model
    model_data = self._load_model_from_path(model_path, config_path, sovits_path, gpt_path)
  File "/app/manager/ModelManager.py", line 242, in _load_model_from_path
    model.load_model()
  File "/app/vits/vits.py", line 40, in load_model
    utils.load_checkpoint(self.model_path, self.net_g_ms)
  File "/app/utils/data_utils.py", line 41, in load_checkpoint
    checkpoint_dict = load(checkpoint_path, map_location=config.system.device)
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1005, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 457, in __init__
    super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
 [in ModelManager.load_model:342]
2024-07-27 21:45:23 [INFO] Loading CHINESE_HUBERT_BASE: /app/data/hubert/chinese_hubert_base [in model_handler.load_ssl:313]
2024-07-27 21:45:23 [ERROR] Failed loading /app/data/hubert/chinese_hubert_base. /app/data/hubert/chinese_hubert_base does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/hubert/chinese_hubert_base/tree/main' for available files. [in model_handler.load_ssl:330]
2024-07-27 21:45:24 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:24 [INFO] Loading CHINESE_HUBERT_BASE: /app/data/hubert/chinese_hubert_base [in model_handler.load_ssl:313]
2024-07-27 21:45:24 [ERROR] Failed loading /app/data/hubert/chinese_hubert_base. /app/data/hubert/chinese_hubert_base does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/hubert/chinese_hubert_base/tree/main' for available files. [in model_handler.load_ssl:330]
2024-07-27 21:45:25 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:25 [INFO] Loading CHINESE_HUBERT_BASE: /app/data/hubert/chinese_hubert_base [in model_handler.load_ssl:313]
2024-07-27 21:45:25 [ERROR] Failed loading /app/data/hubert/chinese_hubert_base. /app/data/hubert/chinese_hubert_base does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/hubert/chinese_hubert_base/tree/main' for available files. [in model_handler.load_ssl:330]
2024-07-27 21:45:26 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:26 [ERROR] Failed to load /app/data/hubert/chinese_hubert_base after 3 retries. [in model_handler.load_ssl:334]
2024-07-27 21:45:26 [INFO] Loading BERT model: /app/data/bert/chinese-roberta-wwm-ext-large [in model_handler.load_bert:168]
2024-07-27 21:45:26 [ERROR] Failed loading /app/data/bert/chinese-roberta-wwm-ext-large. /app/data/bert/chinese-roberta-wwm-ext-large does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/bert/chinese-roberta-wwm-ext-large/tree/None' for available files. [in model_handler.load_bert:182]
2024-07-27 21:45:26 [INFO] Trying to download. [in model_handler.load_bert:183]
2024-07-27 21:45:29 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:29 [INFO] Loading BERT model: /app/data/bert/chinese-roberta-wwm-ext-large [in model_handler.load_bert:168]
2024-07-27 21:45:29 [ERROR] Failed loading /app/data/bert/chinese-roberta-wwm-ext-large. /app/data/bert/chinese-roberta-wwm-ext-large does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/bert/chinese-roberta-wwm-ext-large/tree/None' for available files. [in model_handler.load_bert:182]
2024-07-27 21:45:29 [INFO] Trying to download. [in model_handler.load_bert:183]
2024-07-27 21:45:33 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:33 [INFO] Loading BERT model: /app/data/bert/chinese-roberta-wwm-ext-large [in model_handler.load_bert:168]
2024-07-27 21:45:33 [ERROR] Failed loading /app/data/bert/chinese-roberta-wwm-ext-large. /app/data/bert/chinese-roberta-wwm-ext-large does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/bert/chinese-roberta-wwm-ext-large/tree/None' for available files. [in model_handler.load_bert:182]
2024-07-27 21:45:33 [INFO] Trying to download. [in model_handler.load_bert:183]
2024-07-27 21:45:36 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:36 [ERROR] Failed to load /app/data/bert/chinese-roberta-wwm-ext-large after 3 retries. [in model_handler.load_bert:190]
2024-07-27 21:45:36 [INFO] Loaded checkpoint '/app/data/models/gpt_sovits1/liuying_e8_s2008.pth' [in gpt_sovits.load_sovits:80]
2024-07-27 21:45:37 [INFO] Loaded checkpoint '/app/data/models/gpt_sovits1/liuyingpro-e12.ckpt' [in gpt_sovits.load_gpt:103]
2024-07-27 21:45:37 [INFO] Using Flash Attention [in t2s_model.enable_flash_attn:242]
2024-07-27 21:45:38 [INFO] Number of parameter: 77.49M [in gpt_sovits.load_gpt:121]
2024-07-27 21:45:38 [INFO] Loading BERT model: /app/data/bert/chinese-roberta-wwm-ext-large [in model_handler.load_bert:168]
2024-07-27 21:45:38 [ERROR] Failed loading /app/data/bert/chinese-roberta-wwm-ext-large. /app/data/bert/chinese-roberta-wwm-ext-large does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/bert/chinese-roberta-wwm-ext-large/tree/None' for available files. [in model_handler.load_bert:182]
2024-07-27 21:45:38 [INFO] Trying to download. [in model_handler.load_bert:183]
2024-07-27 21:45:41 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:41 [INFO] Loading BERT model: /app/data/bert/chinese-roberta-wwm-ext-large [in model_handler.load_bert:168]
2024-07-27 21:45:41 [ERROR] Failed loading /app/data/bert/chinese-roberta-wwm-ext-large. /app/data/bert/chinese-roberta-wwm-ext-large does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/bert/chinese-roberta-wwm-ext-large/tree/None' for available files. [in model_handler.load_bert:182]
2024-07-27 21:45:41 [INFO] Trying to download. [in model_handler.load_bert:183]
2024-07-27 21:45:45 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:45 [INFO] Loading BERT model: /app/data/bert/chinese-roberta-wwm-ext-large [in model_handler.load_bert:168]
2024-07-27 21:45:45 [ERROR] Failed loading /app/data/bert/chinese-roberta-wwm-ext-large. /app/data/bert/chinese-roberta-wwm-ext-large does not appear to have a file named config.json. Checkout 'https://huggingface.co//app/data/bert/chinese-roberta-wwm-ext-large/tree/None' for available files. [in model_handler.load_bert:182]
2024-07-27 21:45:45 [INFO] Trying to download. [in model_handler.load_bert:183]
2024-07-27 21:45:48 [INFO] File already exists and verified successfully! [in model_handler._download_model:160]
2024-07-27 21:45:48 [ERROR] Failed to load /app/data/bert/chinese-roberta-wwm-ext-large after 3 retries. [in model_handler.load_bert:190]
2024-07-27 21:45:48 [INFO] Loading failed. 'CHINESE_ROBERTA_WWM_EXT_LARGE' [in ModelManager.load_model:341]
2024-07-27 21:45:48 [ERROR] Traceback (most recent call last):
  File "/app/manager/ModelManager.py", line 322, in load_model
    model_data = self._load_model_from_path(model_path, config_path, sovits_path, gpt_path)
  File "/app/manager/ModelManager.py", line 281, in _load_model_from_path
    model.load_model(self.model_handler)
  File "/app/gpt_sovits/gpt_sovits.py", line 57, in load_model
    self.tokenizer, self.bert_model = self.model_handler.get_bert_model("CHINESE_ROBERTA_WWM_EXT_LARGE")
  File "/app/manager/model_handler.py", line 269, in get_bert_model
    tokenizer, model, _ = self.bert_models[bert_model_name]
KeyError: 'CHINESE_ROBERTA_WWM_EXT_LARGE'
 [in ModelManager.load_model:342]
jinghuashang commented 3 months ago

貌似是模型问题,但是加载了正常vits模型还是不能发出音频

2024-07-27 23:03:28 [INFO] [VITS] id:5 format:wav lang:auto length:1.0 noise:0.33 noisew:0.4 segment_size:50 [in views.voice_vits_api:146]
2024-07-27 23:03:28 [INFO] [VITS] len:8 text:你好,こんにちは [in views.voice_vits_api:148]
2024-07-27 23:03:28 [DEBUG] [JA]你好,こんにちは[JA] [in sentence.sentence_split_and_markup:184]
WARNING: JPCommonLabel_make() in jcomon_label.c: No phoneme.
[2024-07-27 23:05:29 +0800] [1] [CRITICAL] WORKER TIMEOUT (pid:27)
[2024-07-27 23:05:30 +0800] [1] [ERROR] Worker (pid:27) was sent SIGKILL! Perhaps out of memory?
[2024-07-27 23:05:30 +0800] [28] [INFO] Booting worker with pid: 28
Artrajz commented 3 months ago

Worker (pid:27) was sent SIGKILL! Perhaps out of memory?

请问机器性能足够吗?这里说是内存不足,不过合成过慢导致超时也会报这个错。可以使用wsgi而不是gunicorn启动服务,看看是否还会出现问题,在docker-compose.yaml中添加command: [ 'python', 'app.py' ]

完整文件如下

version: '3.4'
services:
  vits:
    image: artrajz/vits-simple-api:latest
    restart: always
    ports:
      - 23456:23456
    environment:
      LANG: 'C.UTF-8'
      TZ: Asia/Shanghai #timezone
    command: [ 'python', 'app.py' ]
    volumes:
      - ./data:/app/data # 挂载模型文件夹
#      - ./config.py:/app/config.py # 挂载配置文件
      - ./config.yaml:/app/config.yaml # 挂载配置文件
      - ./logs:/app/logs # logging logs
      - ./gunicorn_config.py:/app/gunicorn_config.py # gunicorn configuration
      - ./pyopenjtalk/open_jtalk_dic_utf_8-1.11:/usr/local/lib/python3.10/site-packages/pyopenjtalk/open_jtalk_dic_utf_8-1.11 #pyopentjalk
      - ./nltk_data:/usr/local/share/nltk_data
jinghuashang commented 3 months ago

Worker (pid:27) was sent SIGKILL! Perhaps out of memory?

请问机器性能足够吗?这里说是内存不足,不过合成过慢导致超时也会报这个错。可以使用wsgi而不是gunicorn启动服务,看看是否还会出现问题,在docker-compose.yaml中添加command: [ 'python', 'app.py' ]

完整文件如下

version: '3.4'
services:
  vits:
    image: artrajz/vits-simple-api:latest
    restart: always
    ports:
      - 23456:23456
    environment:
      LANG: 'C.UTF-8'
      TZ: Asia/Shanghai #timezone
    command: [ 'python', 'app.py' ]
    volumes:
      - ./data:/app/data # 挂载模型文件夹
#      - ./config.py:/app/config.py # 挂载配置文件
      - ./config.yaml:/app/config.yaml # 挂载配置文件
      - ./logs:/app/logs # logging logs
      - ./gunicorn_config.py:/app/gunicorn_config.py # gunicorn configuration
      - ./pyopenjtalk/open_jtalk_dic_utf_8-1.11:/usr/local/lib/python3.10/site-packages/pyopenjtalk/open_jtalk_dic_utf_8-1.11 #pyopentjalk
      - ./nltk_data:/usr/local/share/nltk_data

感谢 ,加上command: [ 'python', 'app.py' ]就正常了

jinghuashang commented 3 months ago

使用有中文的vits模型会报错,如下

2024-07-29 13:54:50 [INFO] [VITS] id:0 format:wav lang:auto length:1.0 noise:0.33 noisew:0.4 segment_size:50 [in views.voice_vits_api:146]
2024-07-29 13:54:50 [INFO] [VITS] len:8 text:你好,こんにちは [in views.voice_vits_api:148]
2024-07-29 13:54:50 [ERROR] Exception on /voice/vits [POST] [in app.log_exception:1744]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask_cors/extension.py", line 178, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/app/tts_app/voice_api/auth.py", line 10, in check_api_key
    return func(*args, **kwargs)
  File "/app/tts_app/voice_api/views.py", line 197, in voice_vits_api
    audio = tts_manager.vits_infer(state)
  File "/app/manager/TTSManager.py", line 274, in vits_infer
    sentences_list = sentence_split_and_markup(state["text"], state["segment_size"], state["lang"],
  File "/app/utils/sentence.py", line 178, in sentence_split_and_markup
    markup_language(i,
  File "/app/utils/sentence.py", line 22, in markup_language
    pattern = config.LanguageIdentification.split_pattern
AttributeError: 'Config' object has no attribute 'LanguageIdentification'

模型来源 https://github.com/MaxMax2016/VITSModels?tab=readme-ov-file#nene--nanami--rong--tang

Artrajz commented 3 months ago

AttributeError: 'Config' object has no attribute 'LanguageIdentification'

已提交修复该问题 https://github.com/Artrajz/vits-simple-api/commit/deea020d60952505b6bd6c2744a3f6a17e90fd3b 近期添加了在配置修改正则表达式的功能,代码里配置未正确获取导致的

jinghuashang commented 3 months ago

哇大佬真快

jinghuashang commented 3 months ago

拉的新镜像就正常了