Skip to content

Conversation

JackyHe398
Copy link

现存问题

现在如果想在GPTSoVITS的推理模组上开发小工具,几乎必须import inference_webui.py。但是模型会在import 的时候加载进GPU里,会导致很多问题,例如:

  1. 无法指定GPU,一机多卡情况下永远选择GPU0(微调时用于选择GPU的逻辑没有加进推理模块里面)
  2. 多卡推理无法进行
  3. import速度慢
  4. 逻辑较混乱

改动

此PR通过将所有的模型加载逻辑合进同一个function(def load_models(device_override):)里面解决上述问题。并且在load_model 和get_tts_wav上也加上device_override 来指定推理用卡。device_override 应为cuda序号,如“cuda:0”/"cuda:1",而不设置override的情况下默认为None,将使用默认逻辑(使用global,现时为"cuda"或"cpu")。未改动其他function名和文件名。

兼容

小幅度修改inference_cli 和 inference_gui,以兼容此PR。inference_webui_fast 方面,因未见复用 inference_webui 逻辑而没有做出任何更动。

使用及未来优化

单卡推理需要在推理之前加上一行“load_models()”,无需其他改动。多卡推理可以为每GPU开一个process,每一个process均需要调用load_models()+get_tts_wav(),并加上相应的cuda序号。考虑兼容性及 @XXXXRT666 提及“inference_webui 不是用import读的”,现时采用改动最小的方法。后续需优化代码逻辑,包括分开推理逻辑,争取可以在threading跑以减少CPU缓存占用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant