3
3
# Need devel version cause we need /usr/include/cudnn.h
4
4
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
5
5
6
- ENV DEEPSPEECH_REPO=#DEEPSPEECH_REPO#
7
- ENV DEEPSPEECH_SHA=#DEEPSPEECH_SHA#
6
+ ENV DEEPSPEECH_REPO=#DEEPSPEECH_REPO# \
7
+ DEEPSPEECH_SHA=#DEEPSPEECH_SHA#
8
8
9
9
# >> START Install base software
10
10
@@ -39,62 +39,59 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
39
39
sox \
40
40
unzip \
41
41
wget \
42
- zlib1g-dev
43
-
44
- RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
45
- RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
46
-
47
- # Install Bazel
48
- RUN curl -LO "https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel_3.1.0-linux-x86_64.deb"
49
- RUN dpkg -i bazel_*.deb
50
-
51
- # Try and free some space
52
- RUN rm -rf /var/lib/apt/lists/*
42
+ zlib1g-dev; \
43
+ update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
44
+ update-alternatives --install /usr/bin/python python /usr/bin/python3 1; \
45
+ # Install Bazel \
46
+ curl -LO "https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel_3.1.0-linux-x86_64.deb" && dpkg -i bazel_*.deb; \
47
+ # Try and free some space \
48
+ rm -rf /var/lib/apt/lists/* bazel_*.deb
53
49
54
50
# << END Install base software
55
51
56
52
# >> START Configure Tensorflow Build
57
53
58
54
# GPU Environment Setup
59
- ENV TF_NEED_ROCM 0
60
- ENV TF_NEED_OPENCL_SYCL 0
61
- ENV TF_NEED_OPENCL 0
62
- ENV TF_NEED_CUDA 1
63
- ENV TF_CUDA_PATHS "/usr,/usr/local/cuda-10.1,/usr/lib/x86_64-linux-gnu/"
64
- ENV TF_CUDA_VERSION 10.1
65
- ENV TF_CUDNN_VERSION 7.6
66
- ENV TF_CUDA_COMPUTE_CAPABILITIES 6.0
67
- ENV TF_NCCL_VERSION 2.8
68
-
69
- # Common Environment Setup
70
- ENV TF_BUILD_CONTAINER_TYPE GPU
71
- ENV TF_BUILD_OPTIONS OPT
72
- ENV TF_BUILD_DISABLE_GCP 1
73
- ENV TF_BUILD_ENABLE_XLA 0
74
- ENV TF_BUILD_PYTHON_VERSION PYTHON3
75
- ENV TF_BUILD_IS_OPT OPT
76
- ENV TF_BUILD_IS_PIP PIP
77
-
78
- # Other Parameters
79
- ENV CC_OPT_FLAGS -mavx -mavx2 -msse4.1 -msse4.2 -mfma
80
- ENV TF_NEED_GCP 0
81
- ENV TF_NEED_HDFS 0
82
- ENV TF_NEED_JEMALLOC 1
83
- ENV TF_NEED_OPENCL 0
84
- ENV TF_CUDA_CLANG 0
85
- ENV TF_NEED_MKL 0
86
- ENV TF_ENABLE_XLA 0
87
- ENV TF_NEED_AWS 0
88
- ENV TF_NEED_KAFKA 0
89
- ENV TF_NEED_NGRAPH 0
90
- ENV TF_DOWNLOAD_CLANG 0
91
- ENV TF_NEED_TENSORRT 0
92
- ENV TF_NEED_GDR 0
93
- ENV TF_NEED_VERBS 0
94
- ENV TF_NEED_OPENCL_SYCL 0
95
-
96
- ENV PYTHON_BIN_PATH /usr/bin/python3.6
97
- ENV PYTHON_LIB_PATH /usr/local/lib/python3.6/dist-packages
55
+ ENV TF_NEED_ROCM=0 \
56
+ TF_NEED_OPENCL_SYCL=0 \
57
+ TF_NEED_OPENCL=0 \
58
+ TF_NEED_CUDA=1 \
59
+ TF_CUDA_PATHS="/usr,/usr/local/cuda-10.1,/usr/lib/x86_64-linux-gnu/" \
60
+ TF_CUDA_VERSION=10.1 \
61
+ TF_CUDNN_VERSION=7.6 \
62
+ TF_CUDA_COMPUTE_CAPABILITIES=6.0 \
63
+ TF_NCCL_VERSION=2.8 \
64
+ # Common Environment Setup \
65
+ TF_BUILD_CONTAINER_TYPE=GPU \
66
+ TF_BUILD_OPTIONS=OPT \
67
+ TF_BUILD_DISABLE_GCP=1 \
68
+ TF_BUILD_ENABLE_XLA=0 \
69
+ TF_BUILD_PYTHON_VERSION=PYTHON3 \
70
+ TF_BUILD_IS_OPT=OPT \
71
+ TF_BUILD_IS_PIP=PIP \
72
+ # Build client.cc and install Python client and decoder bindings \
73
+ TFDIR=/DeepSpeech/tensorflow \
74
+ # Allow Python printing utf-8 \
75
+ PYTHONIOENCODING=UTF-8 \
76
+ # Other Parameters \
77
+ CC_OPT_FLAGS="-mavx -mavx2 -msse4.1 -msse4.2 -mfma" \
78
+ TF_NEED_GCP=0 \
79
+ TF_NEED_HDFS=0 \
80
+ TF_NEED_JEMALLOC=1 \
81
+ TF_NEED_OPENCL=0 \
82
+ TF_CUDA_CLANG=0 \
83
+ TF_NEED_MKL=0 \
84
+ TF_ENABLE_XLA=0 \
85
+ TF_NEED_AWS=0 \
86
+ TF_NEED_KAFKA=0 \
87
+ TF_NEED_NGRAPH=0 \
88
+ TF_DOWNLOAD_CLANG=0 \
89
+ TF_NEED_TENSORRT=0 \
90
+ TF_NEED_GDR=0 \
91
+ TF_NEED_VERBS=0 \
92
+ TF_NEED_OPENCL_SYCL=0 \
93
+ PYTHON_BIN_PATH=/usr/bin/python3.6 \
94
+ PYTHON_LIB_PATH=/usr/local/lib/python3.6/dist-packages
98
95
99
96
# << END Configure Tensorflow Build
100
97
@@ -103,37 +100,31 @@ ENV PYTHON_LIB_PATH /usr/local/lib/python3.6/dist-packages
103
100
# Running bazel inside a `docker build` command causes trouble, cf:
104
101
# https://github.com/bazelbuild/bazel/issues/134
105
102
# The easiest solution is to set up a bazelrc file forcing --batch.
106
- RUN echo "startup --batch" >>/etc/bazel.bazelrc
107
103
# Similarly, we need to workaround sandboxing issues:
108
104
# https://github.com/bazelbuild/bazel/issues/418
109
- RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
110
- >> /etc/bazel.bazelrc
105
+ RUN echo "startup --batch" >>/etc/bazel.bazelrc; \
106
+ echo "build --spawn_strategy=standalone --genrule_strategy=standalone" >> /etc/bazel.bazelrc
111
107
112
108
# << END Configure Bazel
113
109
114
110
WORKDIR /
115
111
116
- RUN git clone --recursive $DEEPSPEECH_REPO DeepSpeech
117
- WORKDIR /DeepSpeech
118
- RUN git fetch origin $DEEPSPEECH_SHA && git checkout $DEEPSPEECH_SHA
119
- RUN git submodule sync tensorflow/ && git submodule update --init tensorflow/
120
- RUN git submodule sync kenlm/ && git submodule update --init kenlm/
112
+ RUN git clone --recursive $DEEPSPEECH_REPO DeepSpeech && \
113
+ cd /DeepSpeech && \
114
+ git fetch origin $DEEPSPEECH_SHA && git checkout $DEEPSPEECH_SHA; \
115
+ git submodule sync tensorflow/ && git submodule update --init tensorflow/; \
116
+ git submodule sync kenlm/ && git submodule update --init kenlm/
121
117
122
118
# >> START Build and bind
123
-
124
- WORKDIR /DeepSpeech/tensorflow
125
-
126
119
# Fix for not found script https://github.com/tensorflow/tensorflow/issues/471
127
- RUN ./configure
128
-
129
120
# Using CPU optimizations:
130
121
# -mtune=generic -march=x86-64 -msse -msse2 -msse3 -msse4.1 -msse4.2 -mavx.
131
122
# Adding --config=cuda flag to build using CUDA.
132
123
133
124
# passing LD_LIBRARY_PATH is required cause Bazel doesn't pickup it from environment
134
125
135
126
# Build DeepSpeech
136
- RUN bazel build \
127
+ RUN cd /DeepSpeech/tensorflow && ./configure && bazel build \
137
128
--workspace_status_command="bash native_client/bazel_workspace_status_cmd.sh" \
138
129
--config=monolithic \
139
130
--config=cuda \
@@ -151,36 +142,22 @@ RUN bazel build \
151
142
--copt=-fvisibility=hidden \
152
143
//native_client:libdeepspeech.so \
153
144
--verbose_failures \
154
- --action_env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
145
+ --action_env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH} && \
146
+ cp bazel-bin/native_client/libdeepspeech.so /DeepSpeech/native_client/ && \
147
+ rm -fr /root/.cache/*
155
148
156
- # Copy built libs to /DeepSpeech/native_client
157
- RUN cp bazel-bin/native_client/libdeepspeech.so /DeepSpeech/native_client/
158
-
159
- # Build client.cc and install Python client and decoder bindings
160
- ENV TFDIR /DeepSpeech/tensorflow
161
-
162
- RUN nproc
163
-
164
- WORKDIR /DeepSpeech/native_client
165
- RUN make NUM_PROCESSES=$(nproc) deepspeech
166
-
167
- WORKDIR /DeepSpeech
168
- RUN cd native_client/python && make NUM_PROCESSES=$(nproc) bindings
169
- RUN pip3 install --upgrade native_client/python/dist/*.whl
170
-
171
- RUN cd native_client/ctcdecode && make NUM_PROCESSES=$(nproc) bindings
172
- RUN pip3 install --upgrade native_client/ctcdecode/dist/*.whl
149
+ RUN cd /DeepSpeech/native_client && make NUM_PROCESSES=$(nproc) deepspeech ; \
150
+ cd /DeepSpeech/native_client/python && make NUM_PROCESSES=$(nproc) bindings; \
151
+ pip3 install --upgrade dist/*.whl; \
152
+ cd /DeepSpeech/native_client/ctcdecode && make NUM_PROCESSES=$(nproc) bindings; \
153
+ pip3 install --upgrade dist/*.whl
173
154
174
155
# << END Build and bind
175
156
176
- # Allow Python printing utf-8
177
- ENV PYTHONIOENCODING UTF-8
178
-
179
157
# Build KenLM in /DeepSpeech/kenlm folder
180
158
WORKDIR /DeepSpeech/kenlm
181
- RUN wget -O - https://gitlab.com/libeigen/eigen/-/archive/3.3.8/eigen-3.3.8.tar.bz2 | tar xj
182
- RUN ls -hal
183
- RUN mkdir -p build && \
159
+ RUN wget -O - https://gitlab.com/libeigen/eigen/-/archive/3.3.8/eigen-3.3.8.tar.bz2 | tar xj; \
160
+ mkdir -p build && \
184
161
cd build && \
185
162
EIGEN3_ROOT=/DeepSpeech/kenlm/eigen-3.3.8 cmake .. && \
186
163
make -j $(nproc)
0 commit comments