From d64cba667f5c0ce1d69be07171bc1aec90730960 Mon Sep 17 00:00:00 2001 From: psr Date: Wed, 5 Apr 2023 22:38:53 +0000 Subject: [PATCH 1/3] docker support --- .dockerignore | 4 ++++ Dockerfile | 35 +++++++++++++++++++++++++++++++++++ setup-docker.sh | 4 ++++ start-docker.sh | 14 ++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 setup-docker.sh create mode 100755 start-docker.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d316141 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +/models +/training +/voices +/bin diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffff6ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 AS stage1 +ARG DEBIAN_FRONTEND=noninteractive +ARG TZ=America/Los_Angeles +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get update +RUN apt install -y curl wget git +RUN adduser --disabled-password --gecos '' --shell /bin/bash user +USER user +ENV HOME=/home/user +WORKDIR $HOME +RUN mkdir $HOME/.cache $HOME/.config && chmod -R 777 $HOME +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py39_23.1.0-1-Linux-x86_64.sh +RUN chmod +x Miniconda3-py39_23.1.0-1-Linux-x86_64.sh +RUN ./Miniconda3-py39_23.1.0-1-Linux-x86_64.sh -b -p /home/user/miniconda +ENV PATH="$HOME/miniconda/bin:$PATH" +RUN conda init +RUN conda install python=3.9.13 +RUN python3 -m pip install --upgrade pip +RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 + +FROM stage1 AS stage2 +RUN mkdir /home/user/ai-voice-cloning +WORKDIR /home/user/ai-voice-cloning +COPY --chown=user:user modules modules + +FROM stage2 AS stage3 +RUN python3 -m pip install -r ./modules/tortoise-tts/requirements.txt +RUN python3 -m pip install -e ./modules/tortoise-tts/ +RUN python3 -m pip install -r ./modules/dlas/requirements.txt +RUN python3 -m pip install -e ./modules/dlas/ +ADD requirements.txt requirements.txt +RUN python3 -m pip install -r ./requirements.txt +ADD --chown=user:user . /home/user/ai-voice-cloning + +CMD ["python", "./src/main.py", "--listen", "0.0.0.0:7680"] diff --git a/setup-docker.sh b/setup-docker.sh new file mode 100755 index 0000000..c4ca008 --- /dev/null +++ b/setup-docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash +git submodule init +git submodule update --remote +docker build -t ai-voice-cloning . diff --git a/start-docker.sh b/start-docker.sh new file mode 100755 index 0000000..b11279f --- /dev/null +++ b/start-docker.sh @@ -0,0 +1,14 @@ +#!/bin/bash +CMD="python3 ./src/main.py $@" +# CMD="bash" +CPATH="/home/user/ai-voice-cloning" +docker run --rm --gpus all \ + --mount "type=bind,src=$PWD/models,dst=$CPATH/models" \ + --mount "type=bind,src=$PWD/training,dst=$CPATH/training" \ + --mount "type=bind,src=$PWD/voices,dst=$CPATH/voices" \ + --mount "type=bind,src=$PWD/bin,dst=$CPATH/bin" \ + --workdir $CPATH \ + --user "$(id -u):$(id -g)" \ + --net host \ + -it ai-voice-cloning $CMD + From c018bfca9c1e969806ef39dc6b7fe500f8be8cc1 Mon Sep 17 00:00:00 2001 From: psr Date: Fri, 7 Apr 2023 23:14:05 +0000 Subject: [PATCH 2/3] docker: add ffmpeg for whisper and general cleanup --- Dockerfile | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index ffff6ba..e0fb05a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,37 @@ -FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 AS stage1 +FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04 + ARG DEBIAN_FRONTEND=noninteractive -ARG TZ=America/Los_Angeles +ARG TZ=UTC +ARG MINICONDA_VERSION=23.1.0-1 +ARG PYTHON_VERSION=3.9.13 + RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN apt-get update -RUN apt install -y curl wget git +RUN apt install -y curl wget git ffmpeg RUN adduser --disabled-password --gecos '' --shell /bin/bash user USER user ENV HOME=/home/user WORKDIR $HOME RUN mkdir $HOME/.cache $HOME/.config && chmod -R 777 $HOME -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py39_23.1.0-1-Linux-x86_64.sh -RUN chmod +x Miniconda3-py39_23.1.0-1-Linux-x86_64.sh -RUN ./Miniconda3-py39_23.1.0-1-Linux-x86_64.sh -b -p /home/user/miniconda +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py39_$MINICONDA_VERSION-Linux-x86_64.sh +RUN chmod +x Miniconda3-py39_$MINICONDA_VERSION-Linux-x86_64.sh +RUN ./Miniconda3-py39_$MINICONDA_VERSION-Linux-x86_64.sh -b -p /home/user/miniconda ENV PATH="$HOME/miniconda/bin:$PATH" RUN conda init -RUN conda install python=3.9.13 +RUN conda install python=$PYTHON_VERSION RUN python3 -m pip install --upgrade pip RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 -FROM stage1 AS stage2 -RUN mkdir /home/user/ai-voice-cloning -WORKDIR /home/user/ai-voice-cloning +RUN mkdir $HOME/ai-voice-cloning +WORKDIR $HOME/ai-voice-cloning COPY --chown=user:user modules modules -FROM stage2 AS stage3 RUN python3 -m pip install -r ./modules/tortoise-tts/requirements.txt RUN python3 -m pip install -e ./modules/tortoise-tts/ RUN python3 -m pip install -r ./modules/dlas/requirements.txt RUN python3 -m pip install -e ./modules/dlas/ ADD requirements.txt requirements.txt RUN python3 -m pip install -r ./requirements.txt -ADD --chown=user:user . /home/user/ai-voice-cloning +ADD --chown=user:user . $HOME/ai-voice-cloning CMD ["python", "./src/main.py", "--listen", "0.0.0.0:7680"] From 9afafc69c19233fe5501e52d69134e9dc9ef3a2b Mon Sep 17 00:00:00 2001 From: psr Date: Fri, 7 Apr 2023 23:15:13 +0000 Subject: [PATCH 3/3] docker: add training script --- train-docker.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 train-docker.sh diff --git a/train-docker.sh b/train-docker.sh new file mode 100755 index 0000000..cd19b1a --- /dev/null +++ b/train-docker.sh @@ -0,0 +1,15 @@ +#!/bin/bash +CMD="python3 ./src/train.py --yaml $1" +# ipc host is one way to increase the shared memory for the container +# more info here https://github.com/pytorch/pytorch#docker-image +CPATH="/home/user/ai-voice-cloning" +docker run --rm --gpus all \ + --mount "type=bind,src=$PWD/models,dst=$CPATH/models" \ + --mount "type=bind,src=$PWD/training,dst=$CPATH/training" \ + --mount "type=bind,src=$PWD/voices,dst=$CPATH/voices" \ + --mount "type=bind,src=$PWD/bin,dst=$CPATH/bin" \ + --mount "type=bind,src=$PWD/src,dst=$CPATH/src" \ + --workdir $CPATH \ + --ipc host \ + --user "$(id -u):$(id -g)" \ + -it ai-voice-cloning $CMD