Add Pre-Commit Hook

Update Docker
This commit is contained in:
XXXXRT666 2025-04-30 20:40:30 +01:00
parent bf90e8f4aa
commit 8c6abbf930
7 changed files with 140 additions and 87 deletions

View File

@ -26,16 +26,16 @@ jobs:
matrix:
include:
- cuda_version: 12.4
use_fasterwhisper: false
lite: false
tag_prefix: lite-cu124
- cuda_version: 12.4
use_fasterwhisper: true
lite: true
tag_prefix: cu124
- cuda_version: 12.8
use_fasterwhisper: false
lite: false
tag_prefix: lite-cu128
- cuda_version: 12.8
use_fasterwhisper: true
lite: true
tag_prefix: cu128
steps:
@ -93,12 +93,11 @@ jobs:
context: .
file: ./Dockerfile
push: false
platforms: linux/amd64,linux/arm64
build-args: |
USE_FUNASR=true
USE_FASTERWHISPER=${{ matrix.use_fasterwhisper }}
LITE=${{ matrix.lite }}
CUDA_VERSION=${{ matrix.cuda_version }}
WGET_CMD=wget -nv --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404
SKIP_CHECK=true
WORKFLOW=true
tags: |
xxxxrt666/gpt-sovits:${{ matrix.tag_prefix }}-${{ needs.generate-meta.outputs.tag }}
xxxxrt666/gpt-sovits:latest-${{ matrix.tag_prefix }}

15
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,15 @@
ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.7
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]
args: [--line-length=120]

View File

@ -0,0 +1,30 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
cd "$SCRIPT_DIR" || exit 1
cd .. || exit 1
WORKFLOW=${WORKFLOW:-"false"}
TARGETPLATFORM=${TARGETPLATFORM:-"linux/amd64"}
if [ "$WORKFLOW" = "true" ]; then
WGET_CMD="wget --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404"
else
WGET_CMD="wget -nv --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404"
fi
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
eval "$WGET_CMD -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh"
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
eval "$WGET_CMD -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-aarch.sh"
else
exit 1
fi
bash anaconda.sh -b -p "$HOME/anaconda3"
rm anaconda.sh

63
Docker/setup.sh Normal file
View File

@ -0,0 +1,63 @@
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
cd "$SCRIPT_DIR" || exit 1
cd .. || exit 1
set -e
WORKFLOW=${WORKFLOW:-"false"}
LITE=${LITE:-"false"}
if [ "$WORKFLOW" = "true" ]; then
WGET_CMD="wget --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404"
else
WGET_CMD="wget -nv --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404"
fi
USE_FUNASR=false
USE_FASTERWHISPER=false
if [ "$LITE" = "true" ]; then
USE_FUNASR=true
USE_FASTERWHISPER=false
else
USE_FUNASR=true
USE_FASTERWHISPER=true
fi
if [ "$USE_FUNASR" = "true" ]; then
echo "Downloading funasr..." &&
$WGET_CMD "https://huggingface.co/XXXXRT/GPT-SoVITS-Pretrained/resolve/main/funasr.zip" &&
unzip funasr.zip -d tools/asr/models/ &&
rm -rf funasr.zip
else
echo "Skipping funasr download"
fi
if [ "$USE_FASTERWHISPER" = "true" ]; then
echo "Downloading faster-whisper..." &&
$WGET_CMD "https://huggingface.co/XXXXRT/GPT-SoVITS-Pretrained/resolve/main/faster-whisper.zip" &&
unzip faster-whisper.zip -d tools/asr/models/ &&
rm -rf faster-whisper.zip
else
echo "Skipping faster-whisper download"
fi
source "$HOME/anaconda3/etc/profile.d/conda.sh"
if [ "$LITE" = "true" ]; then
bash install.sh --device "CU${CUDA_VERSION//./}" --source HF --skip-check "$WORKFLOW"
elif [ "$LITE" = "false" ]; then
bash install.sh --device "CU${CUDA_VERSION//./}" --source HF --skip-check "$WORKFLOW" --download-uvr5
else
exit 1
fi
pip cache purge
pip show torch
rm -rf "$HOME/.cache" /tmp/* /var/tmp/*

View File

@ -1,15 +1,15 @@
ARG CUDA_VERSION=12.4
FROM nvidia/cuda:${CUDA_VERSION}.1-cudnn-runtime-ubuntu22.04
ARG CUDA_VERSION
ENV CUDA_VERSION=${CUDA_VERSION}
FROM nvidia/cuda:${CUDA_VERSION}.1-cudnn-devel-ubuntu22.04
LABEL maintainer="XXXXRT"
LABEL version="V4-0429"
LABEL version="V4-0501"
LABEL description="Docker image for GPT-SoVITS"
ARG CUDA_VERSION=12.4
ENV CUDA_VERSION=${CUDA_VERSION}
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
@ -29,76 +29,35 @@ WORKDIR /workspace/GPT-SoVITS
COPY . /workspace/GPT-SoVITS
ARG WGET_CMD=wget --tries=25 --wait=5 --read-timeout=40 --retry-on-http-error=404
ENV WGET_CMD=${WGET_CMD}
ARG LITE=false
ENV LITE=${LITE}
RUN echo "== /usr ==" && du -h --max-depth=2 /usr | sort -hr | head -n 10 && \
echo "== /opt ==" && du -h --max-depth=2 /opt | sort -hr | head -n 10 && \
echo "== /root ==" && du -h --max-depth=2 /root | sort -hr | head -n 10 && \
echo "==workspace==" && du -h --max-depth=2 /workspace/GPT-SoVITS | sort -hr | head -n 10
ARG WORKFLOW=false
ENV WORKFLOW=${WORKFLOW}
RUN eval "$WGET_CMD -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh" && \
bash anaconda.sh -b -p /root/anaconda3 && \
rm anaconda.sh
ARG TARGETPLATFORM=linux/amd64
ENV TARGETPLATFORM=${TARGETPLATFORM}
RUN bash Docker/anaconda_install.sh
RUN echo "== /usr ==" && du -h --max-depth=2 /usr | sort -hr | head -n 10 && \
echo "== /opt ==" && du -h --max-depth=2 /opt | sort -hr | head -n 10 && \
echo "== /root ==" && du -h --max-depth=2 /root | sort -hr | head -n 10 && \
echo "==workspace==" && du -h --max-depth=2 /workspace/GPT-SoVITS | sort -hr | head -n 10
RUN echo "== $HOME/anaconda3/pkgs ==" && du -h --max-depth=2 $HOME/anaconda3/pkgs | sort -hr | head -n 10 && \
echo "== $HOME/anaconda3 ==" && du -h --max-depth=2 $HOME/anaconda3 | sort -hr | head -n 10
ARG USE_FUNASR=false
ARG USE_FASTERWHISPER=false
RUN if [ "$USE_FUNASR" = "true" ]; then \
echo "Downloading funasr..." && \
$WGET_CMD "https://huggingface.co/XXXXRT/GPT-SoVITS-Pretrained/resolve/main/funasr.zip" && \
unzip funasr.zip -d tools/asr/models/ && \
rm -rf funasr.zip ; \
else \
echo "Skipping funasr download" ; \
fi
RUN if [ "$USE_FASTERWHISPER" = "true" ]; then \
echo "Downloading faster-whisper..." && \
$WGET_CMD "https://huggingface.co/XXXXRT/GPT-SoVITS-Pretrained/resolve/main/faster-whisper.zip" && \
unzip faster-whisper.zip -d tools/asr/models/ && \
rm -rf faster-whisper.zip ; \
else \
echo "Skipping faster-whisper download" ; \
fi
RUN echo "== /usr ==" && du -h --max-depth=2 /usr | sort -hr | head -n 10 && \
echo "== /opt ==" && du -h --max-depth=2 /opt | sort -hr | head -n 10 && \
echo "== /root ==" && du -h --max-depth=2 /root | sort -hr | head -n 10 && \
echo "==workspace==" && du -h --max-depth=2 /workspace/GPT-SoVITS | sort -hr | head -n 10
ENV PATH="/root/anaconda3/bin:$PATH"
ENV PATH="$HOME/anaconda3/bin:$PATH"
SHELL ["/bin/bash", "-c"]
RUN conda create -n GPTSoVITS python=3.10 -y
ENV PATH="/usr/local/cuda/bin:$PATH"
ENV CUDA_HOME="/usr/local/cuda"
ENV MAKEFLAGS="-j$(nproc)"
ARG SKIP_CHECK=false
ENV SKIP_CHECK=${SKIP_CHECK}
RUN bash Docker/setup.sh
RUN source /root/anaconda3/etc/profile.d/conda.sh && \
conda activate GPTSoVITS && \
bash install.sh --device CU${CUDA_VERSION//./} --source HF --skip-check ${SKIP_CHECK} --download-uvr5 && \
pip cache purge && \
pip show torch
RUN echo "== /usr ==" && du -h --max-depth=2 /usr | sort -hr | head -n 10 && \
echo "== /opt ==" && du -h --max-depth=2 /opt | sort -hr | head -n 10 && \
echo "== /root ==" && du -h --max-depth=2 /root | sort -hr | head -n 10 && \
echo "==workspace==" && du -h --max-depth=2 /workspace/GPT-SoVITS | sort -hr | head -n 10
RUN rm -rf /root/anaconda3/pkgs
RUN echo "== $HOME/anaconda3/pkgs ==" && du -h --max-depth=2 $HOME/anaconda3/pkgs | sort -hr | head -n 10 && \
echo "== $HOME/anaconda3 ==" && du -h --max-depth=2 $HOME/anaconda3 | sort -hr | head -n 10
EXPOSE 9871 9872 9873 9874 9880
CMD ["/bin/bash", "-c", "source /root/anaconda3/etc/profile.d/conda.sh && conda activate GPTSoVITS && export PYTHONPATH=$(pwd) && exec bash"]
ENV PYTHONPATH="/workspace/GPT-SoVITS"
CMD ["/bin/bash", "-c", "source $HOME/anaconda3/etc/profile.d/conda.sh && exec bash"]

View File

@ -16,7 +16,6 @@ services:
- /workspace/tools/asr/models
- /workspace/tools/uvr5/uvr5_weights
environment:
- PYTHONPATH=/workspace/GPT-SoVITS
- is_half=true
tty: true
stdin_open: true
@ -38,7 +37,6 @@ services:
- /workspace/tools/asr/models
- /workspace/tools/uvr5/uvr5_weights
environment:
- PYTHONPATH=/workspace/GPT-SoVITS
- is_half=true
tty: true
stdin_open: true

View File

@ -17,7 +17,7 @@ trap 'echo "Error Occured at \"$BASH_COMMAND\" with exit code $?"; exit 1' ERR
USE_CUDA=false
USE_ROCM=false
USE_CPU=false
SKIP_CHECK=false
WORKFLOW=${WORKFLOW:-"false"}
USE_HF=false
USE_HF_MIRROR=false
@ -66,17 +66,6 @@ while [[ $# -gt 0 ]]; do
esac
shift 2
;;
--skip-check)
case "$2" in
true)
SKIP_CHECK=true
;;
*)
:
;;
esac
shift 2
;;
--device)
case "$2" in
CU124)
@ -204,7 +193,7 @@ if [ "$DOWNLOAD_UVR5" = "true" ]; then
fi
fi
if [ "$USE_CUDA" = true ] && [ $SKIP_CHECK = false ]; then
if [ "$USE_CUDA" = true ] && [ "$WORKFLOW" = false ]; then
echo "Checking for CUDA installation..."
if command -v nvidia-smi &>/dev/null; then
echo "CUDA found."
@ -215,7 +204,7 @@ if [ "$USE_CUDA" = true ] && [ $SKIP_CHECK = false ]; then
fi
fi
if [ "$USE_ROCM" = true ] && [ $SKIP_CHECK = false ]; then
if [ "$USE_ROCM" = true ] && [ "$WORKFLOW" = false ]; then
echo "Checking for ROCm installation..."
if [ -d "/opt/rocm" ]; then
echo "ROCm found."