This commit is contained in:
Adam Labay 2025-05-28 18:12:02 -05:00 committed by GitHub
commit fcc7dc40f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 69 additions and 61 deletions

View file

@ -2,10 +2,17 @@ FROM nvidia/cuda:12.2.0-devel-ubuntu22.04
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=UTC ARG TZ=UTC
ARG MINICONDA_VERSION=23.1.0-1 ARG PYTHON_VERSION=3.11.10
ARG PYTHON_VERSION=3.11 ARG UID=1001
ARG UID=1000 ARG GID=1001
ARG GID=1000
# Repositories
ARG BASE_REPO=https://github.com/labay-adam/ai-voice-cloning
ARG RVC_REPO=https://huggingface.co/Jmica/rvc/resolve/main/rvc_lightweight.zip?download=true
ARG FAIRSEQ_REPO=https://github.com/VarunGumma/fairseq
ARG PYFASTMP3DECODER_REPO=https://github.com/neonbjb/pyfastmp3decoder.git
ARG PIPELINE_REPO=https://github.com/JarodMica/rvc-tts-pipeline.git@lightweight#egg=rvc_tts_pipe
ARG WHISPERX_REPO=https://github.com/m-bain/whisperx.git
# TZ # TZ
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@ -20,7 +27,24 @@ RUN apt-get install -y \
p7zip-full \ p7zip-full \
gcc \ gcc \
g++ \ g++ \
vim nano
# Python Prereqs
RUN apt-get install -y \
libssl-dev \
liblzma-dev \
libsqlite3-dev \
libctypes-ocaml-dev \
libffi-dev \
libncurses-dev \
libbz2-dev \
libreadline-dev \
tk-dev \
make \
build-essential \
zlib1g-dev \
llvm \
xz-utils
# User # User
RUN groupadd --gid $GID user RUN groupadd --gid $GID user
@ -31,67 +55,49 @@ WORKDIR $HOME
RUN mkdir $HOME/.cache $HOME/.config && chmod -R 777 $HOME RUN mkdir $HOME/.cache $HOME/.config && chmod -R 777 $HOME
# Python # Python
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py39_$MINICONDA_VERSION-Linux-x86_64.sh RUN curl https://pyenv.run/ | bash
RUN chmod +x Miniconda3-py39_$MINICONDA_VERSION-Linux-x86_64.sh ENV PYENV=$HOME/.pyenv/bin
RUN ./Miniconda3-py39_$MINICONDA_VERSION-Linux-x86_64.sh -b -p /home/user/miniconda RUN $PYENV/pyenv install $PYTHON_VERSION
ENV PATH="$HOME/miniconda/bin:$PATH" ENV PYTHON3_BIN=$HOME/.pyenv/versions/$PYTHON_VERSION/bin/python3
RUN conda init USER root
RUN conda install python=$PYTHON_VERSION RUN ln -sf $PYTHON3_BIN /usr/bin/python3
USER user
# Prereqs
RUN python3 -m pip install --upgrade pip RUN python3 -m pip install --upgrade pip
RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 RUN python3 -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# Base path # Base path
RUN mkdir $HOME/ai-voice-cloning RUN git clone $BASE_REPO
WORKDIR $HOME/ai-voice-cloning WORKDIR $HOME/ai-voice-cloning
# Built in modules # Built in modules
COPY --chown=user:user modules modules RUN git submodule init &&\
git submodule update --remote
RUN python3 -m pip install -r ./modules/tortoise-tts/requirements.txt 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 -e ./modules/tortoise-tts/
RUN python3 -m pip install -r ./modules/dlas/requirements.txt RUN python3 -m pip install -r ./modules/dlas/requirements.txt
RUN python3 -m pip install -e ./modules/dlas/ RUN python3 -m pip install -e ./modules/dlas/
# RVC # Stage other modules
RUN \ RUN curl -L $RVC_REPO -o rvc.zip && \
curl -L -o /tmp/rvc.zip https://huggingface.co/Jmica/rvc/resolve/main/rvc_lightweight.zip?download=true &&\ python3 -m zipfile -e rvc.zip ./
7z x /tmp/rvc.zip &&\ RUN git clone $FAIRSEQ_REPO && \
rm -f /tmp/rvc.zip python3 -m pip wheel ./fairseq -w ./fairseq/wheels
USER root RUN git clone --recurse-submodules $PYFASTMP3DECODER_REPO && \
RUN \ python3 -m pip wheel ./pyfastmp3decoder -w ./pyfastmp3decoder/wheels
chown user:user rvc -R &&\
chmod -R u+rwX,go+rX,go-w rvc # Install dependencies
USER user
RUN python3 -m pip install -r ./rvc/requirements.txt RUN python3 -m pip install -r ./rvc/requirements.txt
RUN python3 -m pip install ./fairseq/wheels/fairseq-*.whl
# Fairseq RUN python3 -m pip install git+$PIPELINE_REPO
# Using patched version for Python 3.11 due to https://github.com/facebookresearch/fairseq/issues/5012
RUN python3 -m pip install git+https://github.com/liyaodev/fairseq
# RVC Pipeline
RUN python3 -m pip install git+https://github.com/JarodMica/rvc-tts-pipeline.git@lightweight#egg=rvc_tts_pipe
# Deepspeed
RUN python3 -m pip install deepspeed RUN python3 -m pip install deepspeed
RUN python3 -m pip install ./pyfastmp3decoder/wheels/pyfastmp3decoder-*.whl
# PyFastMP3Decoder RUN python3 -m pip install git+$WHISPERX_REPO
RUN python3 -m pip install cython RUN python3 -m pip install -r requirements.txt
RUN git clone https://github.com/neonbjb/pyfastmp3decoder.git
RUN \
cd pyfastmp3decoder &&\
git submodule update --init --recursive &&\
python setup.py install &&\
cd ..
# WhisperX
RUN python3 -m pip install git+https://github.com/m-bain/whisperx.git
# Main requirements
ADD requirements.txt requirements.txt
RUN python3 -m pip install -r ./requirements.txt
# The app
ADD --chown=user:user . $HOME/ai-voice-cloning
ENV IN_DOCKER=true ENV IN_DOCKER=true
ENV PYTHON_VERSION=$PYTHON_VERSION
ENV GRADIO_SERVER_NAME=0.0.0.0
CMD ["./start.sh"] CMD ["./start.sh"]

View file

@ -1,13 +1,17 @@
#!/bin/bash #!/bin/bash
function main() { function main() {
if [ ! -f modules/tortoise-tts/README.md ]; then uid=${uid:-"$(id -u)"}
git submodule init gid=${gid:-"$(id -g)"}
git submodule update if [ "$uid" = "0" ]; then # User is running docker as sudo
uid=1001
fi fi
if [ "$gid" = "0" ]; then # User is running docker as sudo
gid=1001
fi
docker build \ docker build \
--build-arg UID=$(id -u) \ --build-arg UID=$uid \
--build-arg GID=$(id -g) \ --build-arg GID=$gid \
-t ai-voice-cloning \ -t ai-voice-cloning \
. .
} }

View file

@ -1,4 +1,2 @@
#!/bin/bash #!/bin/bash
source ./venv/bin/activate
python3 ./src/train.py --yaml "$1" python3 ./src/train.py --yaml "$1"
deactivate