Fixing docker build for DeepSpeed, introducing build for conda environment
This commit is contained in:
1 parent
7522fa87d6
commit
c7f9b04826
10 files changed
+268
-149
No files matched your search
+3
-2
@@ -172,5 +172,6 @@ cython_debug/
|
|||||||
|
|
||||||
.idea/*
|
.idea/*
|
||||||
|
|
||||||
# Deepspeed build
|
# Docker build
|
||||||
deepspeed/build
|
docker/conda/build
|
||||||
|
docker/deepspeed/build
|
||||||
+12
-6
@@ -2,9 +2,11 @@
|
|||||||
The Docker image currently works on Windows and Linux, optionally supporting NVIDIA GPUs.
|
The Docker image currently works on Windows and Linux, optionally supporting NVIDIA GPUs.
|
||||||
|
|
||||||
## General Remarks
|
## General Remarks
|
||||||
- The resulting Docker image is 22 GB in size. Building might require even more disk space temporarily.
|
- The resulting Docker image is 21 GB in size. Building might require even more disk space temporarily.
|
||||||
- Build time depends on your hardware and internet connection. Expect at least 10min to be normal.
|
- Another 15 GB is required for building DeepSpeed
|
||||||
- The Docker build:
|
- Build time depends on your hardware and internet connection. Expect at least 20-30min to be normal for a full build.
|
||||||
|
- This includes building the conda environment as well as DeepSpeed, which is the basis for the alltalk Docker image.
|
||||||
|
- The Docker build for alltalk:
|
||||||
- Downloads XTTS as default TTS engine
|
- Downloads XTTS as default TTS engine
|
||||||
- Enables RVC by default
|
- Enables RVC by default
|
||||||
- Downloads all supported RVC models
|
- Downloads all supported RVC models
|
||||||
@@ -55,18 +57,22 @@ There are various arguments to customize the build and start of the docker image
|
|||||||
- Example: `docker-build.sh --tts_model piper`
|
- Example: `docker-build.sh --tts_model piper`
|
||||||
- `--tag` allows to choose the docker tag. Defaults to `latest`.
|
- `--tag` allows to choose the docker tag. Defaults to `latest`.
|
||||||
- Example: `docker-build.sh --tag mytag`
|
- Example: `docker-build.sh --tag mytag`
|
||||||
|
- `--clean` allows remove existing dependency build like conda environment or DeepSpeed.
|
||||||
|
- Example: `docker-build.sh --clean`
|
||||||
|
|
||||||
### Arguments for `docker-start.sh`
|
### Arguments for `docker-start.sh`
|
||||||
- `--config` lets you choose a config JSON file which can subset of `confignew.json`. This allows you to change only
|
- `--config` lets you choose a config JSON file which can subset of `confignew.json`. This allows you to change only
|
||||||
few values and leave the rest as defined in the default `confignew.json` file.
|
few values and leave the rest as defined in the default `confignew.json` file.
|
||||||
- Example: `docker-build.sh --config /my/config/file.json` with content `{"branding": "My Brand "}` will just change
|
- Example: `docker-start.sh --config /my/config/file.json` with content `{"branding": "My Brand "}` will just change
|
||||||
the branding in `confignew.json`.
|
the branding in `confignew.json`.
|
||||||
- `--voices` lets you add voices for the TTS engine in WAV format. You have to specify the folder containing all
|
- `--voices` lets you add voices for the TTS engine in WAV format. You have to specify the folder containing all
|
||||||
voice files.
|
voice files.
|
||||||
- Example: `docker-build.sh --voices /my/voices/dir`
|
- Example: `docker-start.sh --voices /my/voices/dir`
|
||||||
- `--rvc_voices` similar to voices, this option lets you pick the folder containing the RVC models.
|
- `--rvc_voices` similar to voices, this option lets you pick the folder containing the RVC models.
|
||||||
- Example: `docker-build.sh --rvc_vices /my/rvc/voices/dir`
|
- Example: `docker-start.sh --rvc_vices /my/rvc/voices/dir`
|
||||||
- `--no_ui` allows you to not expose port 7852 for the gradio interface. Note that you still have to set `launch_gradio`
|
- `--no_ui` allows you to not expose port 7852 for the gradio interface. Note that you still have to set `launch_gradio`
|
||||||
to `false` via JSON file passed to `--config`.
|
to `false` via JSON file passed to `--config`.
|
||||||
|
- `--tag` allows to choose the docker tag of the image to run. Defaults to `latest`.
|
||||||
|
- Example: `docker-start.sh --tag mytag`
|
||||||
- Since the above commands only address the most important options, you might pass additional arbitrary docker commands
|
- Since the above commands only address the most important options, you might pass additional arbitrary docker commands
|
||||||
to the `docker-start.sh`.
|
to the `docker-start.sh`.
|
||||||
+40
-48
@@ -4,23 +4,21 @@ FROM continuumio/miniconda3:24.7.1-0
|
|||||||
ARG TTS_MODEL="xtts"
|
ARG TTS_MODEL="xtts"
|
||||||
ENV TTS_MODEL=$TTS_MODEL
|
ENV TTS_MODEL=$TTS_MODEL
|
||||||
|
|
||||||
ARG CUDA_VERSION="12.1.1"
|
ARG ALLTALK_DIR=/opt/alltalk
|
||||||
ENV CUDA_VERSION=$CUDA_VERSION
|
|
||||||
|
|
||||||
ARG PYTHON_VERSION=3.11.9
|
|
||||||
ENV PYTHON_VERSION=$PYTHON_VERSION
|
|
||||||
|
|
||||||
ARG PYTORCH_VERSION=2.2.1
|
|
||||||
ENV PYTORCH_VERSION=$PYTORCH_VERSION
|
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-l", "-c"]
|
SHELL ["/bin/bash", "-l", "-c"]
|
||||||
ENV SHELL=/bin/bash
|
ENV SHELL=/bin/bash
|
||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ENV CUDA_DOCKER_ARCH=all
|
ENV CUDA_DOCKER_ARCH=all
|
||||||
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
|
||||||
ENV NVIDIA_VISIBLE_DEVICES=all
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||||
|
ENV CONDA_AUTO_UPDATE_CONDA="false"
|
||||||
|
|
||||||
|
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Installation/Basic Utilities
|
||||||
|
##############################################################################
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get upgrade -y
|
apt-get upgrade -y
|
||||||
@@ -34,59 +32,47 @@ RUN <<EOR
|
|||||||
apt-get clean && rm -rf /var/lib/apt/lists/*
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
WORKDIR /alltalk
|
WORKDIR ${ALLTALK_DIR}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
# Create a conda environment and install dependencies:
|
# Create a conda environment and install dependencies:
|
||||||
ARG INSTALL_ENV_DIR=/alltalk/alltalk_environment/env
|
##############################################################################
|
||||||
ENV CONDA_AUTO_UPDATE_CONDA="false"
|
COPY docker/conda/build/environment-*.yml environment.yml
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
CUDA_SHORT_VERSION=${CUDA_VERSION%.*}
|
RESULT=$( { conda env create -f environment.yml ; } 2>&1 )
|
||||||
|
|
||||||
conda create -y -n "alltalk" -c conda-forge python=${PYTHON_VERSION}
|
|
||||||
conda activate alltalk
|
|
||||||
RESULT=$( { conda install -y \
|
|
||||||
gcc_linux-64 \
|
|
||||||
gxx_linux-64 \
|
|
||||||
pytorch=${PYTORCH_VERSION} \
|
|
||||||
pytorch-cuda=${CUDA_SHORT_VERSION} \
|
|
||||||
torchvision \
|
|
||||||
torchaudio \
|
|
||||||
libaio \
|
|
||||||
nvidia/label/cuda-${CUDA_SHORT_VERSION}.0::cuda-toolkit \
|
|
||||||
faiss-gpu=1.9.0 \
|
|
||||||
conda-forge::ffmpeg=7.1.0 \
|
|
||||||
conda-forge::portaudio=19.7.0 \
|
|
||||||
-c pytorch \
|
|
||||||
-c anaconda \
|
|
||||||
-c nvidia ; } 2>&1 )
|
|
||||||
|
|
||||||
if echo $RESULT | grep -izq error ; then
|
if echo $RESULT | grep -izq error ; then
|
||||||
echo "Failed to install conda dependencies 2: $RESULT"
|
echo "Failed to install conda dependencies: $RESULT"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
conda clean -a && pip cache purge
|
conda clean -a && pip cache purge
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
# Install python dependencies (cannot use --no-deps because requirements are not complete)
|
# Install python dependencies (cannot use --no-deps because requirements are not complete)
|
||||||
|
##############################################################################
|
||||||
COPY system/config system/config
|
COPY system/config system/config
|
||||||
COPY system/requirements/requirements_standalone.txt system/requirements/requirements_standalone.txt
|
COPY system/requirements/requirements_standalone.txt system/requirements/requirements_standalone.txt
|
||||||
COPY system/requirements/requirements_parler.txt system/requirements/requirements_parler.txt
|
COPY system/requirements/requirements_parler.txt system/requirements/requirements_parler.txt
|
||||||
ENV PIP_CACHE_DIR=/alltalk/pip_cache
|
ENV PIP_CACHE_DIR=${ALLTALK_DIR}/pip_cache
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
conda activate alltalk
|
conda activate alltalk
|
||||||
|
|
||||||
mkdir /alltalk/pip_cache
|
mkdir ${ALLTALK_DIR}k/pip_cache
|
||||||
pip install --no-cache-dir --cache-dir=/alltalk/pip_cache -r system/requirements/requirements_standalone.txt
|
pip install --no-cache-dir --cache-dir=${ALLTALK_DIR}/pip_cache -r system/requirements/requirements_standalone.txt
|
||||||
pip install --no-cache-dir --cache-dir=/alltalk/pip_cache --upgrade gradio==4.32.2
|
pip install --no-cache-dir --cache-dir=${ALLTALK_DIR}/pip_cache --upgrade gradio==4.32.2
|
||||||
# Parler:
|
# Parler:
|
||||||
pip install --no-cache-dir --cache-dir=/alltalk/pip_cache -r system/requirements/requirements_parler.txt
|
pip install --no-cache-dir --cache-dir=${ALLTALK_DIR}/pip_cache -r system/requirements/requirements_parler.txt
|
||||||
|
|
||||||
conda clean --all --force-pkgs-dirs -y && pip cache purge
|
conda clean --all --force-pkgs-dirs -y && pip cache purge
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
# Deepspeed:
|
##############################################################################
|
||||||
|
# Install DeepSpeed
|
||||||
|
##############################################################################
|
||||||
RUN mkdir -p /tmp/deepseped
|
RUN mkdir -p /tmp/deepseped
|
||||||
COPY deepspeed/build/*.whl /tmp/deepspeed/
|
COPY docker/deepspeed/build/*.whl /tmp/deepspeed/
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
DEEPSPEED_WHEEL=$(realpath /tmp/deepspeed/*.whl)
|
DEEPSPEED_WHEEL=$(realpath /tmp/deepspeed/*.whl)
|
||||||
conda activate alltalk
|
conda activate alltalk
|
||||||
@@ -103,11 +89,9 @@ RUN <<EOR
|
|||||||
conda clean --all --force-pkgs-dirs -y && pip cache purge
|
conda clean --all --force-pkgs-dirs -y && pip cache purge
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
### Deepspeed requires cutlass:
|
##############################################################################
|
||||||
###RUN git clone --depth 1 --branch "v3.5.1" https://github.com/NVIDIA/cutlass /alltalk/cutlass
|
|
||||||
###ENV CUTLASS_PATH=/alltalk/cutlass
|
|
||||||
|
|
||||||
# Writing scripts to start alltalk:
|
# Writing scripts to start alltalk:
|
||||||
|
##############################################################################
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
cat << EOF > start_alltalk.sh
|
cat << EOF > start_alltalk.sh
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
@@ -141,7 +125,9 @@ EOR
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Create script to execute firstrun.py:
|
##############################################################################
|
||||||
|
# Create script to execute firstrun.py and run it:
|
||||||
|
##############################################################################
|
||||||
RUN echo $'#!/usr/bin/env bash \n\
|
RUN echo $'#!/usr/bin/env bash \n\
|
||||||
source ~/.bashrc \n\
|
source ~/.bashrc \n\
|
||||||
conda activate alltalk \n\
|
conda activate alltalk \n\
|
||||||
@@ -150,18 +136,24 @@ python ./system/config/firstrun.py $@' > ./start_firstrun.sh
|
|||||||
RUN chmod +x start_firstrun.sh
|
RUN chmod +x start_firstrun.sh
|
||||||
RUN ./start_firstrun.sh --tts_model $TTS_MODEL
|
RUN ./start_firstrun.sh --tts_model $TTS_MODEL
|
||||||
|
|
||||||
RUN mkdir -p /alltalk/outputs
|
RUN mkdir -p ${ALLTALK_DIR}/outputs
|
||||||
RUN mkdir -p /root/.triton/autotune
|
RUN mkdir -p /root/.triton/autotune
|
||||||
|
|
||||||
# Enabling deepspeed for all models:
|
##############################################################################
|
||||||
|
# Enable deepspeed for all models:
|
||||||
|
##############################################################################
|
||||||
RUN find . -name model_settings.json -exec sed -i -e 's/"deepspeed_enabled": false/"deepspeed_enabled": true/g' {} \;
|
RUN find . -name model_settings.json -exec sed -i -e 's/"deepspeed_enabled": false/"deepspeed_enabled": true/g' {} \;
|
||||||
|
|
||||||
# Downloading all RVC models:
|
##############################################################################
|
||||||
|
# Download all RVC models:
|
||||||
|
##############################################################################
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
jq -r '.[]' system/tts_engines/rvc_files.json > /tmp/rvc_files.txt
|
jq -r '.[]' system/tts_engines/rvc_files.json > /tmp/rvc_files.txt
|
||||||
xargs -n 1 curl --create-dirs --output-dir models/rvc_base -LO < /tmp/rvc_files.txt
|
xargs -n 1 curl --create-dirs --output-dir models/rvc_base -LO < /tmp/rvc_files.txt
|
||||||
rm -f /tmp/rvc_files.txt
|
rm -f /tmp/rvc_files.txt
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
## Start alltalk:
|
##############################################################################
|
||||||
|
# Start alltalk:
|
||||||
|
##############################################################################
|
||||||
ENTRYPOINT ["sh", "-c", "./start_alltalk.sh"]
|
ENTRYPOINT ["sh", "-c", "./start_alltalk.sh"]
|
||||||
+21
-21
@@ -1,10 +1,13 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
|
. ${SCRIPT_DIR=}/docker/variables.sh
|
||||||
|
|
||||||
TTS_MODEL=xtts
|
TTS_MODEL=xtts
|
||||||
CUDA_VERSION=12.1.1
|
|
||||||
PYTHON_VERSION=3.11.9
|
|
||||||
PYTORCH_VERSION=2.2.1
|
|
||||||
DOCKER_TAG=latest
|
DOCKER_TAG=latest
|
||||||
|
CLEAN=false
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
@@ -17,10 +20,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
PYTHON_VERSION="$2"
|
PYTHON_VERSION="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--pytorch-version)
|
|
||||||
PYTORCH_VERSION="$2"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--tts_model)
|
--tts_model)
|
||||||
TTS_MODEL="$2"
|
TTS_MODEL="$2"
|
||||||
shift
|
shift
|
||||||
@@ -29,6 +28,9 @@ while [ "$#" -gt 0 ]; do
|
|||||||
DOCKER_TAG="$2"
|
DOCKER_TAG="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--clean)
|
||||||
|
CLEAN=true
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
printf '%s\n' "Invalid argument ($1)"
|
printf '%s\n' "Invalid argument ($1)"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -37,29 +39,27 @@ while [ "$#" -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$PYTHON_VERSION -> ${PYTHON_VERSION%.*}"
|
if [ "$CLEAN" = true ]; then
|
||||||
|
rm -rf ${SCRIPT_DIR=}/docker/conda/build
|
||||||
|
rm -rf ${SCRIPT_DIR=}/docker/deepspeed/build
|
||||||
|
fi
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
$SCRIPT_DIR/docker/conda/build-conda-env.sh \
|
||||||
cd $SCRIPT_DIR
|
|
||||||
|
|
||||||
PYTHON_MAJOR_MINOR=${PYTHON_VERSION%.*}
|
|
||||||
$SCRIPT_DIR/deepspeed/build-deepspeed.sh \
|
|
||||||
--cuda-version ${CUDA_VERSION} \
|
--cuda-version ${CUDA_VERSION} \
|
||||||
--python-version ${PYTHON_MAJOR_MINOR} \
|
--python-version ${PYTHON_VERSION}
|
||||||
--pytorch-version ${PYTORCH_VERSION}
|
|
||||||
|
$SCRIPT_DIR/docker/deepspeed/build-deepspeed.sh \
|
||||||
|
--python-version ${PYTHON_VERSION}
|
||||||
|
|
||||||
echo "Starting docker build process using TTS model '${TTS_MODEL}' and docker tag '${DOCKER_TAG}'"
|
echo "Starting docker build process using TTS model '${TTS_MODEL}' and docker tag '${DOCKER_TAG}'"
|
||||||
echo "Building for CUDA $CUDA_VERSION using python ${PYTHON_VERSION} with PyTorch ${PYTORCH_VERSION}"
|
echo "Building for CUDA $CUDA_VERSION using python ${PYTHON_VERSION}"
|
||||||
|
|
||||||
|
|
||||||
docker buildx \
|
docker buildx \
|
||||||
build \
|
build \
|
||||||
--progress=plain \
|
--progress=plain \
|
||||||
--build-arg TTS_MODEL=$TTS_MODEL \
|
--build-arg TTS_MODEL=$TTS_MODEL \
|
||||||
--build-arg CUDA_VERSION=$CUDA_VERSION \
|
--build-arg ALLTALK_DIR=$ALLTALK_DIR \
|
||||||
--build-arg PYTHON_VERSION=$PYTHON_VERSION \
|
|
||||||
--build-arg PYTORCH_VERSION=$PYTORCH_VERSION \
|
|
||||||
-t alltalk_beta:${DOCKER_TAG} \
|
-t alltalk_beta:${DOCKER_TAG} \
|
||||||
.
|
.
|
||||||
|
|
||||||
echo "Docker build process finished"
|
echo "Docker build process finished. Use docker-start.sh to start the container."
|
||||||
+9
-2
@@ -1,7 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
ALLTALK_DIR="/alltalk"
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
. ${SCRIPT_DIR=}/docker/variables.sh
|
||||||
|
|
||||||
WITH_UI=true
|
WITH_UI=true
|
||||||
|
DOCKER_TAG=latest
|
||||||
declare -a ADDITIONAL_ARGS=()
|
declare -a ADDITIONAL_ARGS=()
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
@@ -22,6 +25,10 @@ while [ "$#" -gt 0 ]; do
|
|||||||
--no_ui)
|
--no_ui)
|
||||||
WITH_UI=false
|
WITH_UI=false
|
||||||
;;
|
;;
|
||||||
|
--tag)
|
||||||
|
DOCKER_TAG="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# Allow to pass arbitrary arguments to docker as well to be flexible:
|
# Allow to pass arbitrary arguments to docker as well to be flexible:
|
||||||
ADDITIONAL_ARGS+=( $1 )
|
ADDITIONAL_ARGS+=( $1 )
|
||||||
@@ -58,4 +65,4 @@ docker run \
|
|||||||
--name alltalk \
|
--name alltalk \
|
||||||
"${DOCKER_ARGS[@]}" \
|
"${DOCKER_ARGS[@]}" \
|
||||||
"${ADDITIONAL_ARGS[@]}" \
|
"${ADDITIONAL_ARGS[@]}" \
|
||||||
alltalk_beta:latest &> /dev/stdout
|
alltalk_beta:${DOCKER_TAG} &> /dev/stdout
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
FROM continuumio/miniconda3:24.7.1-0 AS build
|
||||||
|
|
||||||
|
ARG CUDA_VERSION=12.4.1
|
||||||
|
ENV CUDA_VERSION=$CUDA_VERSION
|
||||||
|
|
||||||
|
ARG PYTHON_VERSION=3.11.11
|
||||||
|
ENV PYTHON_VERSION=$PYTHON_VERSION
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-l", "-c"]
|
||||||
|
ENV SHELL=/bin/bash
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV CUDA_DOCKER_ARCH=all
|
||||||
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||||
|
ENV CONDA_AUTO_UPDATE_CONDA="false"
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Installation/Basic Utilities
|
||||||
|
##############################################################################
|
||||||
|
RUN <<EOR
|
||||||
|
apt-get update
|
||||||
|
apt-get upgrade -y
|
||||||
|
apt-get install --no-install-recommends -y \
|
||||||
|
espeak-ng \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
jq \
|
||||||
|
vim
|
||||||
|
|
||||||
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
EOR
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Create a conda environment and install dependencies:
|
||||||
|
##############################################################################
|
||||||
|
RUN <<EOR
|
||||||
|
CUDA_SHORT_VERSION=${CUDA_VERSION%.*}
|
||||||
|
|
||||||
|
conda create -y -n "alltalk" -c conda-forge python=${PYTHON_VERSION}
|
||||||
|
conda activate alltalk
|
||||||
|
RESULT=$( { conda install -y \
|
||||||
|
gcc_linux-64 \
|
||||||
|
gxx_linux-64 \
|
||||||
|
pytorch \
|
||||||
|
pytorch-cuda=${CUDA_SHORT_VERSION} \
|
||||||
|
torchvision \
|
||||||
|
torchaudio \
|
||||||
|
libaio \
|
||||||
|
nvidia/label/cuda-${CUDA_SHORT_VERSION}.0::cuda-toolkit \
|
||||||
|
faiss-gpu=1.9.0 \
|
||||||
|
conda-forge::ffmpeg=7.1.0 \
|
||||||
|
conda-forge::portaudio=19.7.0 \
|
||||||
|
-c pytorch \
|
||||||
|
-c anaconda \
|
||||||
|
-c nvidia ; } 2>&1 )
|
||||||
|
|
||||||
|
if echo $RESULT | grep -izq error ; then
|
||||||
|
echo "Failed to install conda dependencies: $RESULT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
conda clean -a && pip cache purge
|
||||||
|
EOR
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Export conda environment:
|
||||||
|
##############################################################################
|
||||||
|
RUN <<EOR
|
||||||
|
conda activate alltalk
|
||||||
|
conda env export > /environment-cu-${CUDA_VERSION}-cp-${PYTHON_VERSION}.yml
|
||||||
|
EOR
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Make environment file available to docker build output:
|
||||||
|
##############################################################################
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=build /environment-*.yml /
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
|
. ${SCRIPT_DIR=}/../variables.sh
|
||||||
|
|
||||||
|
if [ -f $SCRIPT_DIR/build/environment-cu-${CUDA_VERSION}-cp-${PYTHON_VERSION}.yml ]; then
|
||||||
|
echo "Environment file already exists - skipping..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--cuda-version)
|
||||||
|
CUDA_VERSION="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--python-version)
|
||||||
|
PYTHON_VERSION="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Allow to pass arbitrary arguments to docker as well to be flexible:
|
||||||
|
echo "Unknown argument '$1'"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Building conda environment using python ${PYTHON_VERSION} with CUDA ${CUDA_VERSION}"
|
||||||
|
|
||||||
|
rm -rf build # make sure to properly clean up
|
||||||
|
mkdir -p build
|
||||||
|
|
||||||
|
docker buildx \
|
||||||
|
build \
|
||||||
|
--build-arg CUDA_VERSION=$CUDA_VERSION \
|
||||||
|
--build-arg PYTHON_VERSION=$PYTHON_VERSION \
|
||||||
|
--output=$SCRIPT_DIR/build \
|
||||||
|
.
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
ARG CUDA_VERSION=12.1.1
|
FROM continuumio/miniconda3:24.7.1-0
|
||||||
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu22.04
|
|
||||||
|
|
||||||
ARG PYTHON_VERSION=3.11
|
ARG DEEPSPEED_VERSION=0.16.2
|
||||||
ENV PYTHON_VERSION=$PYTHON_VERSION
|
|
||||||
|
|
||||||
ARG PYTORCH_VERSION=2.2.1
|
|
||||||
ENV PYTORCH_VERSION=$PYTORCH_VERSION
|
|
||||||
|
|
||||||
ARG DEEPSPEED_VERSION=0.16.1
|
|
||||||
ENV DEEPSPEED_VERSION=$DEEPSPEED_VERSION
|
ENV DEEPSPEED_VERSION=$DEEPSPEED_VERSION
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-l", "-c"]
|
||||||
|
ENV SHELL=/bin/bash
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV CUDA_DOCKER_ARCH=all
|
||||||
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||||
|
ENV CONDA_AUTO_UPDATE_CONDA="false"
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Directories:
|
# Directories:
|
||||||
@@ -21,62 +20,49 @@ RUN mkdir -p ${STAGE_DIR}
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
# Installation/Basic Utilities
|
# Installation/Basic Utilities
|
||||||
##############################################################################
|
##############################################################################
|
||||||
SHELL ["/bin/bash", "-l", "-c"]
|
|
||||||
ENV SHELL=/bin/bash
|
|
||||||
|
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
apt-get update
|
|
||||||
apt-get install --no-install-recommends -y \
|
|
||||||
software-properties-common \
|
|
||||||
ca-certificates
|
|
||||||
|
|
||||||
add-apt-repository ppa:git-core/ppa -y # for latest git
|
|
||||||
add-apt-repository ppa:deadsnakes/ppa -y # for python
|
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get upgrade -y
|
apt-get upgrade -y
|
||||||
apt-get install --no-install-recommends -y \
|
apt-get install --no-install-recommends -y \
|
||||||
build-essential \
|
espeak-ng \
|
||||||
autotools-dev \
|
|
||||||
pdsh \
|
|
||||||
cmake \
|
|
||||||
g++ \
|
|
||||||
gcc \
|
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
vim \
|
jq \
|
||||||
unzip \
|
vim
|
||||||
llvm-dev \
|
|
||||||
git \
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
python${PYTHON_VERSION}-dev \
|
|
||||||
libcupti-dev \
|
|
||||||
libaio-dev
|
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Python & pip
|
# Create a conda environment and install dependencies:
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
COPY build/environment-*.yml environment.yml
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
# Correct symlinks to use the proper python version:
|
RESULT=$( { conda env create -f environment.yml ; } 2>&1 )
|
||||||
PYTHON_MAJOR_VERSION=${PYTHON_VERSION%%.*}
|
|
||||||
rm -f /usr/bin/python${PYTHON_MAJOR_VERSION}
|
|
||||||
ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python${PYTHON_MAJOR_VERSION}
|
|
||||||
ln -s /usr/bin/python3 /usr/bin/python
|
|
||||||
|
|
||||||
curl -O https://bootstrap.pypa.io/pip/3.7/get-pip.py
|
if echo $RESULT | grep -izq error ; then
|
||||||
python get-pip.py
|
echo "Failed to install conda dependencies: $RESULT"
|
||||||
rm get-pip.py
|
exit 1
|
||||||
pip install --upgrade pip
|
fi
|
||||||
|
|
||||||
|
conda clean -a && pip cache purge
|
||||||
EOR
|
EOR
|
||||||
|
|
||||||
# Minimal dependencies needed to build deepspeed:
|
##############################################################################
|
||||||
RUN pip install \
|
# Install python dependencies
|
||||||
|
##############################################################################
|
||||||
|
ENV PIP_CACHE_DIR=/tmp/pip_cache
|
||||||
|
RUN <<EOR
|
||||||
|
conda activate alltalk
|
||||||
|
|
||||||
|
pip install \
|
||||||
deepspeed-kernels \
|
deepspeed-kernels \
|
||||||
scikit-learn \
|
scikit-learn
|
||||||
torch==${PYTORCH_VERSION}
|
EOR
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# DeepSpeed
|
# Clone DeepSpeed sources
|
||||||
##############################################################################
|
##############################################################################
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
git clone https://github.com/microsoft/DeepSpeed.git ${STAGE_DIR}/DeepSpeed
|
git clone https://github.com/microsoft/DeepSpeed.git ${STAGE_DIR}/DeepSpeed
|
||||||
@@ -86,12 +72,15 @@ RUN <<EOR
|
|||||||
EOR
|
EOR
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# DeepSpeed build file
|
# Create DeepSpeed build file
|
||||||
##############################################################################
|
##############################################################################
|
||||||
RUN <<EOR
|
RUN <<EOR
|
||||||
cat << EOF > build_deepspeed.sh
|
cat << EOF > build_deepspeed.sh
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
source ~/.bashrc
|
||||||
mkdir -p /deepspeed
|
mkdir -p /deepspeed
|
||||||
|
|
||||||
|
conda activate alltalk
|
||||||
cd ${STAGE_DIR}/DeepSpeed
|
cd ${STAGE_DIR}/DeepSpeed
|
||||||
DS_BUILD_OPS=1 python setup.py build_ext -j8 bdist_wheel
|
DS_BUILD_OPS=1 python setup.py build_ext -j8 bdist_wheel
|
||||||
mv ${STAGE_DIR}/DeepSpeed/dist/*.whl /deepspeed/
|
mv ${STAGE_DIR}/DeepSpeed/dist/*.whl /deepspeed/
|
||||||
@@ -100,4 +89,7 @@ EOR
|
|||||||
|
|
||||||
RUN chmod +x /build_deepspeed.sh
|
RUN chmod +x /build_deepspeed.sh
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
# Build DeepSpeed:
|
||||||
|
##############################################################################
|
||||||
ENTRYPOINT ["/build_deepspeed.sh"]
|
ENTRYPOINT ["/build_deepspeed.sh"]
|
||||||
@@ -1,28 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CUDA_VERSION=12.1.1
|
|
||||||
PYTHON_VERSION=3.11
|
|
||||||
PYTORCH_VERSION=2.2.1
|
|
||||||
DEEPSPEED_VERSION=0.16.1
|
|
||||||
|
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
cd $SCRIPT_DIR
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
|
. ${SCRIPT_DIR=}/../variables.sh
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--cuda-version)
|
|
||||||
CUDA_VERSION="$2"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--python-version)
|
--python-version)
|
||||||
PYTHON_VERSION="$2"
|
PYTHON_VERSION="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--pytorch-version)
|
|
||||||
PYTORCH_VERSION="$2"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--deepspeed-version)
|
--deepspeed-version)
|
||||||
DEEPSPEED_VERSION="$2"
|
DEEPSPEED_VERSION="$2"
|
||||||
shift
|
shift
|
||||||
@@ -36,24 +25,30 @@ while [ "$#" -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
PYTHON_VERSION_NO_DOT=${PYTHON_VERSION//./}
|
PYTHON_SHORT_VERSION=${PYTHON_VERSION%.*}
|
||||||
|
PYTHON_VERSION_NO_DOT=${PYTHON_SHORT_VERSION//./}
|
||||||
if [[ -n $(find build -name "deepspeed-${DEEPSPEED_VERSION}*-cp${PYTHON_VERSION_NO_DOT}-cp${PYTHON_VERSION_NO_DOT}-*.whl") ]]
|
if [[ -n $(find build -name "deepspeed-${DEEPSPEED_VERSION}*-cp${PYTHON_VERSION_NO_DOT}-cp${PYTHON_VERSION_NO_DOT}-*.whl") ]]
|
||||||
then
|
then
|
||||||
echo "DeepSpeed was already built - skipping..."
|
echo "DeepSpeed was already built - skipping..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Building DeepSpeed $DEEPSPEED_VERSION for CUDA $CUDA_VERSION using python ${PYTHON_VERSION} with PyTorch ${PYTORCH_VERSION}"
|
CONDA_ENV=${SCRIPT_DIR=}/../conda/build/environment-cu-${CUDA_VERSION}-cp-${PYTHON_VERSION}.yml
|
||||||
|
if [ ! -f ${CONDA_ENV} ]; then
|
||||||
|
echo "No conda environment found. Please run 'build-conda-env.sh' first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf build # make sure to properly clean up - we only want 1 wheel at the time
|
echo "Building DeepSpeed $DEEPSPEED_VERSION using python ${PYTHON_VERSION}"
|
||||||
|
|
||||||
|
rm -rf build # make sure to properly clean up
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
|
cp ${CONDA_ENV} ${SCRIPT_DIR=}/build
|
||||||
|
|
||||||
docker buildx \
|
docker buildx \
|
||||||
build \
|
build \
|
||||||
--build-arg CUDA_VERSION=$CUDA_VERSION \
|
|
||||||
--build-arg PYTHON_VERSION=$PYTHON_VERSION \
|
|
||||||
--build-arg PYTORCH_VERSION=$PYTORCH_VERSION \
|
|
||||||
--build-arg DEEPSPEED_VERSION=$DEEPSPEED_VERSION \
|
--build-arg DEEPSPEED_VERSION=$DEEPSPEED_VERSION \
|
||||||
-t deepspeed:cu-$CUDA_VERSION-ds-$DEEPSPEED_VERSION \
|
-t deepspeed:$DEEPSPEED_VERSION \
|
||||||
.
|
.
|
||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
@@ -62,4 +57,4 @@ docker run \
|
|||||||
--gpus=all \
|
--gpus=all \
|
||||||
--name deepspeed \
|
--name deepspeed \
|
||||||
-v $SCRIPT_DIR/build:/deepspeed \
|
-v $SCRIPT_DIR/build:/deepspeed \
|
||||||
deepspeed:cu-$CUDA_VERSION-ds-$DEEPSPEED_VERSION
|
deepspeed:$DEEPSPEED_VERSION
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export CUDA_VERSION=12.4.1
|
||||||
|
export PYTHON_VERSION=3.11.11
|
||||||
|
export DEEPSPEED_VERSION=0.16.2
|
||||||
|
export ALLTALK_DIR=/opt/alltalk
|
||||||
Reference in new issue
Block a user