diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a89ac46a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,74 @@ +FROM python:3.10-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + ffmpeg \ + git \ + gnupg2 \ + unzip \ + wget \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Add nvidia package repositories +RUN apt-get update && \ + apt-get install -y gnupg2 && \ + curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/3bf863cc.pub | apt-key add - && \ + echo "deb https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \ + apt-get update + +# Install CUDA 12.1 +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + cuda-toolkit-12-1 \ + libcublas-12-1 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# this will fail to copy if multiple are present in the same dir +COPY ${CUDNN:-cudnn-linux-x86_64-*_cuda12-archive.tar.xz} /tmp/cudnn.tar.xz + +# Extract and install cuDNN +RUN mkdir /tmp/cudnn +RUN tar -xvf /tmp/cudnn.tar.xz -C /tmp/cudnn && \ + cp -P /tmp/cudnn/*/include/cudnn*.h /usr/local/cuda-12.1/include/ && \ + cp -P /tmp/cudnn/*/lib/libcudnn* /usr/local/cuda-12.1/lib64/ && \ + chmod a+r /usr/local/cuda-12.1/include/cudnn*.h /usr/local/cuda-12.1/lib64/libcudnn* +RUN rm -rf /tmp/cudnn + + # Set environment variables for CUDA and cuDNN +ENV PATH=/usr/local/cuda-12.1/bin:${PATH} +ENV LD_LIBRARY_PATH=/usr/local/cuda-12.1/lib64:${LD_LIBRARY_PATH} + +# Create a symlink for libcublas.so.11 +RUN ln -s /usr/local/cuda-12.1/lib64/libcublas.so.12 /usr/local/cuda-12.1/lib64/libcublas.so.11 + +WORKDIR /workspace + +COPY . /workspace + +RUN pip install --upgrade pip + +RUN pip install -r requirements.txt + +# Install pytorch with CUDA 12.1 support +RUN pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121 + +RUN pip install git+https://github.com/violetdenim/wavmark.git +RUN pip install git+https://github.com/myshell-ai/MeloTTS.git + +RUN python -m unidic download + +RUN pip install -e . + +RUN pip install jupyter + +# Port for jupyter +EXPOSE 8888 + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Set the entrypoint for the container, see entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..b5231b1d --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +download_and_unzip() { + url=$1 + output_zip=$2 + output_dir=$3 + + wget $url -O $output_zip && \ + mkdir -p /tmp/extract_temp && \ + unzip $output_zip -d /tmp/extract_temp && \ + first_folder=$(find /tmp/extract_temp -mindepth 1 -maxdepth 1 -type d | head -n 1) && \ + mkdir -p $output_dir && \ + mv $first_folder/* $output_dir/ && \ + rm -rf /tmp/extract_temp && \ + rm $output_zip +} + +if [ "$1" = "v1" ]; then + echo "Downloading v1 checkpoints..." + download_and_unzip "https://myshell-public-repo-hosting.s3.amazonaws.com/openvoice/checkpoints_1226.zip" "checkpoints_1226.zip" "/workspace/checkpoints_v1" +elif [ "$1" = "v2" ]; then + echo "Downloading v2 checkpoints..." + download_and_unzip "https://myshell-public-repo-hosting.s3.amazonaws.com/openvoice/checkpoints_v2_0417.zip" "checkpoints_v2_0417.zip" "/workspace/checkpoints_v2" +else + echo "Downloading both v1 and v2 checkpoints..." + download_and_unzip "https://myshell-public-repo-hosting.s3.amazonaws.com/openvoice/checkpoints_1226.zip" "checkpoints_1226.zip" "/workspace/checkpoints_v1" + download_and_unzip "https://myshell-public-repo-hosting.s3.amazonaws.com/openvoice/checkpoints_v2_0417.zip" "checkpoints_v2_0417.zip" "/workspace/checkpoints_v2" +fi +echo "Starting Jupyter Notebook..." +jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.notebook_dir='/workspace' & + +wait