From e4a66387bfd7b2b6d31008c6d7f6a1481e63423b Mon Sep 17 00:00:00 2001 From: vladlearns Date: Fri, 7 Jun 2024 15:51:07 +0300 Subject: [PATCH 1/2] feat: docker improvements --- Dockerfile | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 32 +++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1629e7b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +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/* + +COPY cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz /tmp/ + +# Extract and install cuDNN 8.9.7 +RUN tar -xvf /tmp/cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz -C /tmp && \ + cp -P /tmp/cudnn-linux-x86_64-8.9.7.29_cuda12-archive/include/cudnn*.h /usr/local/cuda-12.1/include/ && \ + cp -P /tmp/cudnn-linux-x86_64-8.9.7.29_cuda12-archive/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* + +# 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 From 50b92cef97d006cf7d50a2a06d6d14ba82a61f8a Mon Sep 17 00:00:00 2001 From: Richard Benson Date: Wed, 19 Jun 2024 08:26:51 -0400 Subject: [PATCH 2/2] fix: dont hard code the tar.xz --- Dockerfile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1629e7b0..a89ac46a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,15 +26,18 @@ RUN apt-get update && \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz /tmp/ - -# Extract and install cuDNN 8.9.7 -RUN tar -xvf /tmp/cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz -C /tmp && \ - cp -P /tmp/cudnn-linux-x86_64-8.9.7.29_cuda12-archive/include/cudnn*.h /usr/local/cuda-12.1/include/ && \ - cp -P /tmp/cudnn-linux-x86_64-8.9.7.29_cuda12-archive/lib/libcudnn* /usr/local/cuda-12.1/lib64/ && \ +# 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 + # 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}