Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile, make it more convenient and efficient #603

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker_data
build
*.pyc
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,7 @@ dmypy.json
.models/*
.custom/*
results/*
debug_states/*
debug_states/*

# Ignore docker data files
docker_data
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM nvidia/cuda:12.2.0-base-ubuntu22.04

COPY . /app

RUN apt-get update && \
apt-get install -y --allow-unauthenticated --no-install-recommends \
wget \
Expand All @@ -10,12 +8,10 @@ RUN apt-get update && \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

ENV HOME "/root"
ENV CONDA_DIR "${HOME}/miniconda"
ENV HOME="/root"
ENV CONDA_DIR="${HOME}/miniconda"
ENV PATH="$CONDA_DIR/bin":$PATH
ENV CONDA_AUTO_UPDATE_CONDA=false
ENV PIP_DOWNLOAD_CACHE="$HOME/.pip/cache"
ENV TORTOISE_MODELS_DIR

RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda3.sh \
&& bash /tmp/miniconda3.sh -b -p "${CONDA_DIR}" -f -u \
Expand All @@ -30,5 +26,16 @@ RUN conda create --name tortoise python=3.9 numba inflect \
&& conda activate tortoise \
&& conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia \
&& conda install transformers=4.29.2 \
&& cd /app \
&& python setup.py install
&& conda clean --all \
&& echo "conda activate tortoise; cd /app" >> "${HOME}/.bashrc"

# Cache the pip deps after all the slow Conda deps
COPY requirements.txt /app/requirements.txt
WORKDIR /app
RUN conda activate tortoise \
&& pip install -r requirements.txt --no-cache-dir

# and finally copy the source over
COPY . /app/
RUN conda activate tortoise \
&& pip install . --no-cache-dir
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,7 @@ An easy way to hit the ground running and a good jumping off point depending on
git clone https://github.com/neonbjb/tortoise-tts.git
cd tortoise-tts

docker build . -t tts

docker run --gpus all \
-e TORTOISE_MODELS_DIR=/models \
-v /mnt/user/data/tortoise_tts/models:/models \
-v /mnt/user/data/tortoise_tts/results:/results \
-v /mnt/user/data/.cache/huggingface:/root/.cache/huggingface \
-v /root:/work \
-it tts
./scripts/run_docker.sh
```
This gives you an interactive terminal in an environment that's ready to do some tts. Now you can explore the different interfaces that tortoise exposes for tts.

Expand Down
Empty file added docker_data/data/.gitkeep
Empty file.
Empty file added docker_data/models/.gitkeep
Empty file.
Empty file added docker_data/results/.gitkeep
Empty file.
Empty file added docker_data/work/.gitkeep
Empty file.
15 changes: 15 additions & 0 deletions scripts/run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

docker build . -t tts

pwd=$(pwd)

docker run --gpus all \
-e TORTOISE_MODELS_DIR=/models \
-v $pwd/docker_data/models:/models \
-v $pwd/docker_data/results:/results \
-v $pwd/docker_data/.cache/huggingface:/root/.cache/huggingface \
-v $pwd/docker_data/work:/work \
-it tts