WIP:Docker

This commit is contained in:
wataru 2023-01-11 05:17:29 +09:00
parent 067a7c0296
commit 2fdd3cd099
4 changed files with 36 additions and 54 deletions

2
.gitignore vendored
View File

@ -12,3 +12,5 @@ server/memo.txt
client/lib/dist
client/lib/worklet/dist
# client/demo/dist/ # demo用に残す
docker/cudnn/

View File

@ -1,14 +1,15 @@
FROM debian:bullseye-slim as base
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 as base
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y python3-pip git
RUN apt-get install -y espeak
RUN apt-get install -y cmake
# RUN apt-get install -y espeak
# RUN apt-get install -y cmake
RUN pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
#RUN pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
RUN pip install torch torchvision torchaudio
RUN pip install Cython==0.29.32
RUN pip install numpy==1.22.4
@ -29,65 +30,41 @@ RUN pip install python-multipart==0.0.5
RUN pip install uvicorn==0.18.3
RUN pip install websockets==10.4
RUN pip install pyOpenSSL==23.0.0
RUN pip install onnxruntime-gpu==1.13.1
RUN pip install pyopenjtalk==0.2.0
RUN pip install tensorboard==2.10.0
RUN git clone --depth 1 https://github.com/isletennos/MMVC_Trainer.git -b v1.3.1.3
RUN git clone --depth 1 https://github.com/isletennos/MMVC_Trainer.git -b v1.3.2.2
WORKDIR /MMVC_Trainer/monotonic_align
RUN cythonize -3 -i core.pyx \
&& mv core.cpython-39-x86_64-linux-gnu.so monotonic_align/
RUN python3 setup.py build_ext --inplace
WORKDIR /
ADD dummy /
RUN git clone https://github.com/w-okada/voice-changer.git -b v.1.3.0
RUN git clone --depth 1 https://github.com/w-okada/voice-changer.git -b v.1.3.0
#FROM debian:bullseye-slim
#FROM nvidia/cuda:12.0.0-runtime-ubuntu22.04
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
FROM debian:bullseye-slim
RUN apt-get update \
&& apt-get install -y python3-pip espeak gosu libsndfile1-dev\
&& apt-get install -y python3-pip espeak gosu libsndfile1-dev emacs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ### Copy local resource
# COPY fine_model/G_180000.pth /MMVC_Trainer/fine_model/G_180000.pth
# COPY fine_model/D_180000.pth /MMVC_Trainer/fine_model/D_180000.pth
### Copy from base
COPY --from=base --chmod=777 /usr/local/lib/python3.9/dist-packages /usr/local/lib/python3.9/dist-packages
COPY --from=base --chmod=777 /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
COPY --from=base --chmod=777 /voice-changer /voice-changer
COPY --from=base --chmod=777 /MMVC_Trainer /voice-changer/server/MMVC_Trainer
RUN chmod 0777 /voice-changer/server/MMVC_Trainer
RUN chmod 0777 /voice-changer/server
ADD /setup.sh /voice-changer/server
ADD /exec.sh /voice-changer/server
# # # ### Copy from frontend
# # # ##### MMVC Trainer
# # # COPY --from=front --chmod=777 /MMVC_Trainer /MMVC_Trainer
# # # RUN chmod 0777 /MMVC_Trainer
# # # ADD /setup.sh /MMVC_Trainer/
# # # ADD /exec.sh /MMVC_Trainer/
# # ##### Voice changer Internal
# # COPY --from=front --chmod=777 /voice-changer-internal/frontend/dist /voice-changer-internal/frontend/dist
# # COPY --from=front --chmod=777 /voice-changer-internal/voice-change-service /voice-changer-internal/voice-change-service
# # RUN chmod 0777 /voice-changer-internal/voice-change-service
# # ADD /setup.sh /voice-changer-internal/voice-change-service/
# # ADD /exec.sh /voice-changer-internal/voice-change-service/
# # COPY fine_model/G_180000.pth /voice-changer-internal/voice-change-service/MMVC_Trainer/fine_model/G_180000.pth
# # COPY fine_model/D_180000.pth /voice-changer-internal/voice-change-service/MMVC_Trainer/fine_model/D_180000.pth
# # ## 歴史的な経緯でsetup.shをMMVC_Trainerに置いているのでそこを起動時のWORKDIRにしている。
# # WORKDIR /voice-changer-internal/voice-change-service
# # # ##### Soft VC
# # # COPY --from=front /hubert /hubert
# # # COPY --from=front /acoustic-model /acoustic-model
# # # COPY --from=front /hifigan /hifigan
# # # COPY --from=front /models /models
# # ENTRYPOINT ["/bin/bash", "setup.sh"]
# # CMD [ "-h"]
WORKDIR /voice-changer/server
ENTRYPOINT ["/bin/bash", "setup.sh"]
CMD [ "-h"]

View File

@ -13,16 +13,17 @@ echo "PARAMS: $PARAMS"
# echo "VERBOSE: $VERBOSE"
echo "------"
cd /voice-changer-internal/voice-change-service
#cd /voice-changer-internal/voice-change-service
# 起動
if [ "${MODE}" = "MMVC" ] ; then
if [[ -e /resources/setting.json ]]; then
echo "指定された設定(setting.json)を使用します。"
cp /resources/setting.json ../frontend/dist/assets/setting.json
fi
# if [[ -e /resources/setting.json ]]; then
# echo "指定された設定(setting.json)を使用します。"
# cp /resources/setting.json ../frontend/dist/assets/setting.json
# fi
find /resources/ -type f -name "config.json" | xargs -I{} sh -c 'echo "config.jsonをコピーします。" && cp {} ./'
# find /resources/ -type f -name "config.json" | xargs -I{} sh -c 'echo "config.jsonをコピーします。" && cp {} ./'
find /resources/ -type f -name "*.pth" | xargs -I{} sh -c 'echo "`basename {}`をコピーします。" && cp {} ./'
find /resources/ -type f -name "*.onnx" | xargs -I{} sh -c 'echo "`basename {}`をコピーします。" && cp {} ./'
echo "MMVCを起動します"
python3 MMVCServerSIO.py -t MMVC $PARAMS #2>stderr.txt

View File

@ -115,6 +115,8 @@ class VoiceChanger():
providers = self.onnx_session.get_providers()
print("Providers:", providers)
if "CUDAExecutionProvider" in providers:
if self.settings.gpu < 0 or self.settings.gpu >= self.gpu_num:
self.settings.gpu = 0
provider_options=[{'device_id': self.settings.gpu}]
self.onnx_session.set_providers(providers=["CUDAExecutionProvider"], provider_options=provider_options)
if key == "crossFadeOffsetRate" or key == "crossFadeEndRate":