Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest が動かない #226

Closed
tkm2261 opened this issue Dec 9, 2021 · 4 comments
Closed
Labels

Comments

@tkm2261
Copy link

tkm2261 commented Dec 9, 2021

不具合の内容

下記のGPU版のDocker imageを実行すると、プロセスは立ち上がるが音声合成は失敗する。

docker run --rm --gpus all -p '127.0.0.1:50021:50021' hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest

/opt/voicebox_coreの中身をhttps://github.com/VOICEVOX/voicevox_core/releases/tag/0.9.0 に変えたら動いたので、ただのバージョン問題な気がします。

現象・ログ

立ち上げ時

+ exec gosu user /opt/python/bin/python3 ./run.py --use_gpu --voicevox_dir /opt/voicevox_core/ --voicelib_dir /opt/voicevox_core/ --host 0.0.0.0
Notice: --voicevox_dir is /opt/voicevox_core
Traceback (most recent call last):
  File "/opt/voicevox_engine/voicevox_engine/synthesis_engine/make_synthesis_engine.py", line 35, in make_synthesis_engine
    import core
ImportError: libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory

サンプル実行時

curl -s     -X POST     "localhost:50021/audio_query?speaker=1"    --get --data-urlencode text@text.txt
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/user/.local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/home/user/.local/lib/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc
  File "/home/user/.local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/middleware/cors.py", line 84, in __call__
    await self.app(scope, receive, send)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc
  File "/home/user/.local/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/routing.py", line 259, in handle
    await self.app(scope, receive, send)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/routing.py", line 61, in app
    response = await func(request)
  File "/home/user/.local/lib/python3.8/site-packages/fastapi/routing.py", line 226, in app
    raw_response = await run_endpoint_function(
  File "/home/user/.local/lib/python3.8/site-packages/fastapi/routing.py", line 161, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/home/user/.local/lib/python3.8/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/home/user/.local/lib/python3.8/site-packages/anyio/to_thread.py", line 28, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
  File "/home/user/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 805, in run_sync_in_worker_thread
    return await future
  File "/home/user/.local/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 743, in run
    result = func(*args)
  File "./run.py", line 110, in audio_query
    accent_phrases = engine.create_accent_phrases(text, speaker_id=speaker)
AttributeError: 'SynthesisEngine' object has no attribute 'create_accent_phrases'

再現手順

Ubuntu 20.04で

docker pull hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest
docker run --rm --gpus all -p '127.0.0.1:50021:50021' hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest

期待動作

VOICEVOXのバージョン

たぶん0.9.3

OSの種類/ディストリ/バージョン

  • ubuntu20.04

その他

@aoirint
Copy link
Member

aoirint commented Dec 9, 2021

報告ありがとうございます!

ダイジェスト76c218530652で再現しました。

2つ問題が起きていますね...

実行側ですぐできる対処としては、イメージ起動時docker runのオプションに-e LD_LIBRARY_PATH=/opt/libtorch/libを追加することでしょうか。

以下、修正案についてです。

ImportErrorについては、ベースイメージがUbuntu 20.04の場合、entrypointでrootユーザとしてldconfigを実行するようにすると、ひとまず直ると思います。

#105 (comment) で言及していた問題(libtorch_cuda_cpp.soのみが認識されない)な気がします。

この問題が起きる原因はよくわかっていないのですが、Dockerイメージのビルド中にldconfigを実行したとき、キャッシュ(ld.so.cache)に書き込まれないことがある気がしています(もしくはldconfigの実行がスキップされている)。

しかしベースイメージがUbuntu 18.04の場合、LibTorchの共有ライブラリをldconfigが取り扱えない問題 #116 が起きるので、この回避策は使えないかなと思います。根本的な解決策が見つかるといいのですが...。

create_accent_phrasesについては、リファクタリング #199 のときに入ったバグですね...
製品版コアのモジュールを読み込めなかったときに、MockのEngineが読み込まれますが、こちらにcreate_accent_phrasesを実装していなかったために、Mockが動作しなくなっています。
修正としては、共通の抽象クラスを継承するようにするとか、create_accent_phrasesを単体でモジュール化するとかでしょうか。

@Hiroshiba
Copy link
Member

修正としては、共通の抽象クラスを継承するようにするとか、create_accent_phrasesを単体でモジュール化するとかでしょうか。

個人的には共通の抽象クラスを継承するのが良さそうに感じました。

@aoirint
Copy link
Member

aoirint commented Dec 9, 2021

2つの問題は、それぞれ #228 (Workaround), #227 で修正されると思います。

libtorch_cuda_cpp.soのみがなぜか認識されない問題については、根本的な修正のためにIssue化してもいいかもですが、ONNX化 (#69) できればLibTorchへの依存がなくなるので自動的に消滅すると思いますし、いまのところWorkaroundで保留でいいかなとも思っています。

@aoirint
Copy link
Member

aoirint commented Dec 10, 2021

#228, #227 がマージされ、修正されたのでCloseします。あらためてお試しいただければ!

手元で試したところ、修正版のダイジェスト 06224c3a9020 は以下のコマンドで正常起動し、音声合成も正常動作(製品版コアが動作)しました。

docker pull hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest
docker run --rm --gpus all -p '127.0.0.1:50021:50021' hiroshiba/voicevox_engine:nvidia-ubuntu20.04-latest

@aoirint aoirint closed this as completed Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants