forked from mediatechnologycenter/AvatarForge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-neural-voice
83 lines (62 loc) · 2.88 KB
/
Dockerfile-neural-voice
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
FROM nvidia/cuda:11.4.1-base-ubuntu20.04 as base
ENV DEBIAN_FRONTEND noninteractive
ENV PATH /opt/conda/bin:$PATH
# Update & install packages
RUN apt-get -qq update --fix-missing && \
apt-get -qq install -y bzip2 ca-certificates wget curl git build-essential && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-c"]
WORKDIR /app
# Install miniconda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_4.12.0-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda clean --quiet -tipsy && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc
# Set python env vars
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
ENV FORCE_CUDA 1
ENV PYTORCH_CUDA_ALLOC_CONF max_split_size_mb:512
RUN apt-get -qq update && \
apt-get -qq install -y python3-opencv libsm6 libxext6 && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*
FROM base as backend
WORKDIR /app
### deepspeech ###
RUN conda create -n deepspeech python=3.7
# Make run command use the new environment
SHELL ["conda", "run", "-n", "deepspeech", "/bin/bash", "-c"]
RUN conda install pysoundfile -c conda-forge && \
pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html && \
conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge
COPY requirements_deepspeech.txt .
RUN pip install -r requirements_deepspeech.txt
##############################################
### pyenv ###
RUN conda create -n pyenv python=3.9
# Make run command use the new environment
SHELL ["conda", "run", "-n", "pyenv", "/bin/bash", "-c"]
RUN conda install pysoundfile -c conda-forge && \
conda install pytorch=1.13.0 torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia && \
conda install -c fvcore -c iopath -c conda-forge fvcore iopath && \
conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge && \
conda install pytorch3d -c pytorch3d
COPY requirements.txt .
RUN pip install -r requirements.txt
# Make run command use the new environment
SHELL ["conda", "run", "-n", "base", "/bin/bash", "-c"]
COPY requirements.api.txt .
RUN pip install -r requirements.api.txt
COPY avatar-api ./avatar-api
RUN pip install ./avatar-api --use-feature=in-tree-build && \
rm -rf avatar-api
COPY NeuralVoicePuppetry/neural-code ./neural-code
COPY NeuralVoicePuppetry/neural_voice_backend_api ./neural_voice_backend_api
COPY NeuralVoicePuppetry/gunicorn.conf.py .
CMD [ "conda", "run", "--no-capture-output", "-n", "base", "gunicorn", "-c", "gunicorn.conf.py", "--chdir", "./neural_voice_backend_api", "-k", "uvicorn.workers.UvicornWorker", "app:app" ]