1+ # Please refer to the USING documentation, "Dockerfile for building from source"
2+
13# Need devel version cause we need /usr/include/cudnn.h
2- # for compiling libctc_decoder_with_kenlm.so
3- FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
4+ FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
45
6+ ENV DEEPSPEECH_REPO=#DEEPSPEECH_REPO#
7+ ENV DEEPSPEECH_SHA=#DEEPSPEECH_SHA#
58
69# >> START Install base software
710
811# Get basic packages
912RUN apt-get update && apt-get install -y --no-install-recommends \
1013 apt-utils \
14+ bash-completion \
1115 build-essential \
16+ ca-certificates \
17+ cmake \
1218 curl \
13- wget \
19+ g++ \
20+ gcc \
1421 git \
22+ git-lfs \
23+ libbz2-dev \
24+ libboost-all-dev \
25+ libgsm1-dev \
26+ libltdl-dev \
27+ liblzma-dev \
28+ libmagic-dev \
29+ libpng-dev \
30+ libsox-fmt-mp3 \
31+ libsox-dev \
32+ locales \
33+ openjdk-8-jdk \
34+ pkg-config \
1535 python3 \
1636 python3-dev \
1737 python3-pip \
1838 python3-wheel \
1939 python3-numpy \
20- libcurl3-dev \
21- ca-certificates \
22- gcc \
2340 sox \
24- libsox-fmt-mp3 \
25- htop \
26- nano \
27- cmake \
28- libboost-all-dev \
29- zlib1g-dev \
30- libbz2-dev \
31- liblzma-dev \
32- locales \
33- pkg-config \
34- libpng-dev \
35- libsox-dev \
36- libmagic-dev \
37- libgsm1-dev \
38- libltdl-dev \
39- openjdk-8-jdk \
40- bash-completion \
41- g++ \
42- unzip
43-
44- RUN ln -s -f /usr/bin/python3 /usr/bin/python
41+ unzip \
42+ wget \
43+ zlib1g-dev
4544
46- # Install NCCL 2.2
47- RUN apt-get --no- install-recommends install -qq -y --allow-downgrades --allow-change-held-packages libnccl2=2.3.7-1+cuda10.0 libnccl-dev=2.3.7-1+cuda10.0
45+ RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
46+ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
4847
4948# Install Bazel
50- RUN curl -LO "https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel_0.24.1 -linux-x86_64.deb"
49+ RUN curl -LO "https://github.com/bazelbuild/bazel/releases/download/2.0.0/bazel_2.0.0 -linux-x86_64.deb"
5150RUN dpkg -i bazel_*.deb
5251
53- # Install CUDA CLI Tools
54- RUN apt-get --no-install-recommends install -qq -y cuda-command-line-tools-10-0
55-
56- # Install pip
57- RUN wget https://bootstrap.pypa.io/get-pip.py && \
58- python3 get-pip.py && \
59- rm get-pip.py
60-
6152# << END Install base software
6253
63-
64-
65-
6654# >> START Configure Tensorflow Build
6755
6856# Clone TensorFlow from Mozilla repo
6957RUN git clone https://github.com/mozilla/tensorflow/
7058WORKDIR /tensorflow
71- RUN git checkout r1.15
72-
59+ RUN git checkout r2.2
7360
7461# GPU Environment Setup
62+ ENV TF_NEED_ROCM 0
63+ ENV TF_NEED_OPENCL_SYCL 0
64+ ENV TF_NEED_OPENCL 0
7565ENV TF_NEED_CUDA 1
76- ENV TF_CUDA_PATHS "/usr/ local/cuda,/usr/lib/x86_64-linux-gnu/"
77- ENV TF_CUDA_VERSION 10.0
78- ENV TF_CUDNN_VERSION 7
66+ ENV TF_CUDA_PATHS "/usr,/usr/ local/cuda-10.1 ,/usr/lib/x86_64-linux-gnu/"
67+ ENV TF_CUDA_VERSION 10.1
68+ ENV TF_CUDNN_VERSION 7.6
7969ENV TF_CUDA_COMPUTE_CAPABILITIES 6.0
80- ENV TF_NCCL_VERSION 2.3
70+ ENV TF_NCCL_VERSION 2.4
8171
8272# Common Environment Setup
8373ENV TF_BUILD_CONTAINER_TYPE GPU
@@ -105,14 +95,12 @@ ENV TF_NEED_TENSORRT 0
10595ENV TF_NEED_GDR 0
10696ENV TF_NEED_VERBS 0
10797ENV TF_NEED_OPENCL_SYCL 0
98+
10899ENV PYTHON_BIN_PATH /usr/bin/python3.6
109- ENV PYTHON_LIB_PATH /usr/lib/python3.6/dist-packages
100+ ENV PYTHON_LIB_PATH /usr/local/ lib/python3.6/dist-packages
110101
111102# << END Configure Tensorflow Build
112103
113-
114-
115-
116104# >> START Configure Bazel
117105
118106# Running bazel inside a `docker build` command causes trouble, cf:
@@ -124,39 +112,17 @@ RUN echo "startup --batch" >>/etc/bazel.bazelrc
124112RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
125113 >>/etc/bazel.bazelrc
126114
127- # Put cuda libraries to where they are expected to be
128- RUN mkdir /usr/local/cuda/lib && \
129- ln -s /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/local/cuda/lib/libnccl.so.2 && \
130- ln -s /usr/include/nccl.h /usr/local/cuda/include/nccl.h && \
131- ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
132- ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h
133-
134-
135- # Set library paths
136- ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/lib/x86_64-linux-gnu/:/usr/local/cuda/lib64/stubs/
137-
138115# << END Configure Bazel
139116
117+ WORKDIR /
140118
141- # Copy DeepSpeech repo contents to container's /DeepSpeech
142- COPY . /DeepSpeech/
143-
144- # Alternative clone from GitHub
145- # RUN apt-get update && apt-get install -y git-lfs
146- # WORKDIR /
147- # RUN git lfs install
148- # RUN git clone https://github.com/mozilla/DeepSpeech.git
149-
119+ RUN git clone $DEEPSPEECH_REPO
150120WORKDIR /DeepSpeech
151-
152- RUN DS_NODECODER=1 pip3 --no-cache-dir install .
121+ RUN git checkout $DEEPSPEECH_SHA
153122
154123# Link DeepSpeech native_client libs to tf folder
155124RUN ln -s /DeepSpeech/native_client /tensorflow
156125
157-
158-
159-
160126# >> START Build and bind
161127
162128WORKDIR /tensorflow
@@ -170,59 +136,60 @@ RUN ./configure
170136
171137# passing LD_LIBRARY_PATH is required cause Bazel doesn't pickup it from environment
172138
173-
174139# Build DeepSpeech
175- RUN bazel build --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" --config=monolithic --config=cuda -c opt --copt=-O3 --copt="-D_GLIBCXX_USE_CXX11_ABI=0" --copt=-mtune=generic --copt=-march=x86-64 --copt=-msse --copt=-msse2 --copt=-msse3 --copt=-msse4.1 --copt=-msse4.2 --copt=-mavx --copt=-fvisibility=hidden //native_client:libdeepspeech.so --verbose_failures --action_env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
176-
177- # ##
178- # ## Using TensorFlow upstream should work
179- # ##
180- # # Build TF pip package
181- # RUN bazel build --config=opt --config=cuda --copt="-D_GLIBCXX_USE_CXX11_ABI=0" --copt=-mtune=generic --copt=-march=x86-64 --copt=-msse --copt=-msse2 --copt=-msse3 --copt=-msse4.1 --copt=-msse4.2 --copt=-mavx //tensorflow/tools/pip_package:build_pip_package --verbose_failures --action_env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
182- #
183- # # Build wheel
184- # RUN bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
185- #
186- # # Install tensorflow from our custom wheel
187- # RUN pip3 install /tmp/tensorflow_pkg/*.whl
140+ RUN bazel build \
141+ --workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" \
142+ --config=monolithic \
143+ --config=cuda \
144+ -c opt \
145+ --copt=-O3 \
146+ --copt="-D_GLIBCXX_USE_CXX11_ABI=0" \
147+ --copt=-mtune=generic \
148+ --copt=-march=x86-64 \
149+ --copt=-msse \
150+ --copt=-msse2 \
151+ --copt=-msse3 \
152+ --copt=-msse4.1 \
153+ --copt=-msse4.2 \
154+ --copt=-mavx \
155+ --copt=-fvisibility=hidden \
156+ //native_client:libdeepspeech.so \
157+ --verbose_failures \
158+ --action_env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
188159
189160# Copy built libs to /DeepSpeech/native_client
190161RUN cp /tensorflow/bazel-bin/native_client/libdeepspeech.so /DeepSpeech/native_client/
191162
192- # Install TensorFlow
193- WORKDIR /DeepSpeech/
194- RUN pip3 install tensorflow-gpu==1.15.0
195-
196-
197163# Build client.cc and install Python client and decoder bindings
198164ENV TFDIR /tensorflow
165+
166+ RUN nproc
167+
199168WORKDIR /DeepSpeech/native_client
200- RUN make deepspeech
169+ RUN make NUM_PROCESSES=$(nproc) deepspeech
201170
202171WORKDIR /DeepSpeech
203- RUN cd native_client/python && make bindings
172+ RUN cd native_client/python && make NUM_PROCESSES=$(nproc) bindings
204173RUN pip3 install --upgrade native_client/python/dist/*.whl
205174
206- RUN cd native_client/ctcdecode && make bindings
175+ RUN cd native_client/ctcdecode && make NUM_PROCESSES=$(nproc) bindings
207176RUN pip3 install --upgrade native_client/ctcdecode/dist/*.whl
208177
209-
210178# << END Build and bind
211179
212-
213-
214-
215180# Allow Python printing utf-8
216181ENV PYTHONIOENCODING UTF-8
217182
218183# Build KenLM in /DeepSpeech/native_client/kenlm folder
219184WORKDIR /DeepSpeech/native_client
220- RUN rm -rf kenlm \
221- && git clone --depth 1 https://github.com/kpu/kenlm && cd kenlm \
222- && mkdir -p build \
223- && cd build \
224- && cmake .. \
225- && make -j 4
185+ RUN rm -rf kenlm && \
186+ git clone https://github.com/kpu/kenlm && \
187+ cd kenlm && \
188+ git checkout 87e85e66c99ceff1fab2500a7c60c01da7315eec && \
189+ mkdir -p build && \
190+ cd build && \
191+ cmake .. && \
192+ make -j $(nproc)
226193
227194# Done
228195WORKDIR /DeepSpeech
0 commit comments