Skip to content

Commit 386dd8e

Browse files
Merge pull request NVIDIA#630 from NVIDIA/gh/release
Updating GNMT/PyT/TF for Ampere, fixes in WnD/TF and Jasper/PyT
2 parents 1f92262 + 2356b89 commit 386dd8e

File tree

79 files changed

+1162
-755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1162
-755
lines changed

PyTorch/SpeechRecognition/Jasper/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ checkpoints/
55
datasets/
66
external/tensorrt-inference-server/
77
checkpoints/
8+
triton/model_repo
9+
triton/deploy
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[submodule "external/tensorrt-inference-server"]
2-
path = external/tensorrt-inference-server
3-
url = https://github.com/NVIDIA/tensorrt-inference-server.git
4-
branch = r19.06
1+
[submodule "external/triton-inference-server"]
2+
path = external/triton-inference-server
3+
url = https://github.com/NVIDIA/triton-inference-server
4+
branch = r19.12
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
# Default setting is building on nvidia/cuda:10.1-devel-ubuntu18.04
28+
ARG BASE_IMAGE=nvidia/cuda:10.1-devel-ubuntu18.04
29+
30+
FROM ${BASE_IMAGE}
31+
32+
# Default to use Python3. Allowed values are "2" and "3".
33+
ARG PYVER=3
34+
35+
# Ensure apt-get won't prompt for selecting options
36+
ENV DEBIAN_FRONTEND=noninteractive
37+
ENV PYVER=$PYVER
38+
39+
RUN PYSFX=`[ "$PYVER" != "2" ] && echo "$PYVER" || echo ""` && \
40+
apt-get update && \
41+
apt-get install -y --no-install-recommends \
42+
software-properties-common \
43+
autoconf \
44+
automake \
45+
build-essential \
46+
cmake \
47+
curl \
48+
git \
49+
libopencv-dev \
50+
libopencv-core-dev \
51+
libssl-dev \
52+
libtool \
53+
pkg-config \
54+
python${PYSFX} \
55+
python${PYSFX}-pip \
56+
python${PYSFX}-dev && \
57+
pip${PYSFX} install --upgrade setuptools wheel
58+
59+
RUN PYSFX=`[ "$PYVER" != "2" ] && echo "$PYVER" || echo ""` && \
60+
pip${PYSFX} install --upgrade grpcio-tools
61+
62+
# Build expects "python" executable (not python3).
63+
RUN rm -f /usr/bin/python && \
64+
ln -s /usr/bin/python$PYVER /usr/bin/python
65+
66+
# Build the client library and examples
67+
WORKDIR /workspace
68+
COPY VERSION .
69+
COPY build build
70+
COPY src/clients src/clients
71+
COPY src/core src/core
72+
73+
RUN cd build && \
74+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/workspace/install && \
75+
make -j16 trtis-clients
76+
RUN cd install && \
77+
export VERSION=`cat /workspace/VERSION` && \
78+
tar zcf /workspace/v$VERSION.clients.tar.gz *
79+
80+
# For CI testing need to install a test script.
81+
COPY qa/L0_client_tar/test.sh /tmp/test.sh
82+
83+
# Install an image needed by the quickstart and other documentation.
84+
COPY qa/images/mug.jpg images/mug.jpg
85+
86+
# Install the dependencies needed to run the client examples. These
87+
# are not needed for building but including them allows this image to
88+
# be used to run the client examples. The special upgrade and handling
89+
# of pip is needed to get numpy to install correctly with python2 on
90+
# ubuntu 16.04.
91+
RUN python -m pip install --user --upgrade pip && \
92+
python -m pip install --upgrade install/python/tensorrtserver-*.whl numpy pillow
93+
94+
ENV PATH //workspace/install/bin:${PATH}
95+
ENV LD_LIBRARY_PATH /workspace/install/lib:${LD_LIBRARY_PATH}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit a1f3860ba65c0fd8f2be3adfcab2673efd039348

PyTorch/SpeechRecognition/Jasper/inference.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def parse_args():
5656
parser.add_argument("--wav", type=str, help='absolute path to .wav file (16KHz)')
5757
parser.add_argument("--cpu", action="store_true", help="Run inference on CPU")
5858
parser.add_argument("--ema", action="store_true", help="If available, load EMA model weights")
59+
60+
# FIXME Unused, but passed by Triton helper scripts
61+
parser.add_argument("--pyt_fp16", action='store_true', help='use half precision')
62+
5963
return parser.parse_args()
6064

6165
def calc_wer(data_layer, audio_processor,

PyTorch/SpeechRecognition/Jasper/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(self, cfg):
100100
def forward(self, x):
101101
sh = x.shape
102102

103-
mask = torch.zeros(x.shape).byte()
103+
mask = torch.zeros(x.shape, dtype=torch.bool)
104104
for idx in range(sh[0]):
105105
for _ in range(self.cutout_x_regions):
106106
cutout_x_left = int(random.uniform(0, sh[1] - self.cutout_x_width))
@@ -130,7 +130,7 @@ def __init__(self, cfg):
130130
def forward(self, x):
131131
sh = x.shape
132132

133-
mask = torch.zeros(x.shape, dtype=torch.uint8)
133+
mask = torch.zeros(x.shape, dtype=torch.bool)
134134

135135
for idx in range(sh[0]):
136136
for i in range(self.cutout_rect_regions):
@@ -275,7 +275,7 @@ def __init__(self, in_channels, out_channels, kernel_size, stride=1,
275275

276276
def get_seq_len(self, lens):
277277
return ((lens + 2 * self.padding[0] - self.dilation[0] * (
278-
self.kernel_size[0] - 1) - 1) / self.stride[0] + 1)
278+
self.kernel_size[0] - 1) - 1) // self.stride[0] + 1)
279279

280280
def forward(self, inp):
281281
if self.use_conv_mask:

PyTorch/SpeechRecognition/Jasper/optimizers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def step(self, closure=None):
9898

9999
state['step'] += 1
100100
# Decay the first and second moment running average coefficient
101-
exp_avg.mul_(beta1).add_(1 - beta1, grad)
101+
exp_avg.mul_(beta1).add_(grad, alpha=1 - beta1)
102102
exp_avg_sq.mul_(beta2).addcmul_(1 - beta2, grad, grad)
103103
if amsgrad:
104104
# Maintains the maximum of all 2nd moment running avg. till now
@@ -111,7 +111,7 @@ def step(self, closure=None):
111111
bias_correction1 = 1 - beta1 ** state['step']
112112
bias_correction2 = 1 - beta2 ** state['step']
113113
step_size = group['lr'] * math.sqrt(bias_correction2) / bias_correction1
114-
p.data.add_(-step_size, torch.mul(p.data, group['weight_decay']).addcdiv_(1, exp_avg, denom) )
114+
p.data.add_(torch.mul(p.data, group['weight_decay']).addcdiv_(1, exp_avg, denom), alpha=-step_size)
115115

116116
return loss
117117

@@ -201,7 +201,7 @@ def step(self, closure=None):
201201
if exp_avg_sq == 0:
202202
exp_avg_sq.copy_(norm)
203203
else:
204-
exp_avg_sq.mul_(beta2).add_(1 - beta2, norm)
204+
exp_avg_sq.mul_(beta2).add_(norm, alpha=1 - beta2)
205205

206206
if amsgrad:
207207
# Maintains the maximum of all 2nd moment running avg. till now
@@ -213,11 +213,11 @@ def step(self, closure=None):
213213

214214
grad.div_(denom)
215215
if group['weight_decay'] != 0:
216-
grad.add_(group['weight_decay'], p.data)
216+
grad.add_(p.data, alpha=group['weight_decay'])
217217
if group['grad_averaging']:
218218
grad.mul_(1 - beta1)
219219
exp_avg.mul_(beta1).add_(grad)
220220

221-
p.data.add_(-group['lr'], exp_avg)
221+
p.data.add_(exp_avg, alpha=-group['lr'])
222222

223223
return loss

PyTorch/SpeechRecognition/Jasper/scripts/train.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ CMD+=" --seed=$SEED"
4747
CMD+=" --optimizer=novograd"
4848
CMD+=" --dataset_dir=$DATA_DIR"
4949
CMD+=" --val_manifest=$DATA_DIR/librispeech-dev-clean-wav.json"
50-
CMD+=" --train_manifest=$DATA_DIR/librispeech-train-clean-100-wav.json,"
51-
CMD+="$DATA_DIR/librispeech-train-clean-360-wav.json,"
52-
CMD+="$DATA_DIR/librispeech-train-other-500-wav.json"
50+
CMD+=" --train_manifest=$DATA_DIR/librispeech-train-clean-100-wav.json"
51+
CMD+=",$DATA_DIR/librispeech-train-clean-360-wav.json"
52+
CMD+=",$DATA_DIR/librispeech-train-other-500-wav.json"
5353
CMD+=" --weight_decay=1e-3"
5454
CMD+=" --save_freq=$SAVE_FREQUENCY"
5555
CMD+=" --eval_freq=100"

PyTorch/SpeechRecognition/Jasper/tensorrt/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
ARG FROM_IMAGE_NAME=nvcr.io/nvidia/pytorch:20.03-py3
1+
ARG FROM_IMAGE_NAME=nvcr.io/nvidia/pytorch:19.10-py3
22
FROM ${FROM_IMAGE_NAME}
33

4+
RUN apt-get update && apt-get install -y python3
5+
46
WORKDIR /tmp/onnx-trt
5-
COPY trt/onnx-trt.patch .
7+
COPY tensorrt/onnx-trt.patch .
68
RUN git clone https://github.com/onnx/onnx-tensorrt.git && cd onnx-tensorrt && git checkout 8716c9b && git submodule update --init --recursive && \
79
patch -f < ../onnx-trt.patch && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DGPU_ARCHS="60 70 75" && make -j16 && make install && mv -f /usr/lib/libnvonnx* /usr/lib/x86_64-linux-gnu/ && ldconfig
810

@@ -11,7 +13,7 @@ RUN git clone https://github.com/onnx/onnx-tensorrt.git && cd onnx-tensorrt && g
1113
# At the same step, also install TRT pip reqs
1214
WORKDIR /tmp/pipReqs
1315
COPY requirements.txt /tmp/pipReqs/jocRequirements.txt
14-
COPY trt/requirements.txt /tmp/pipReqs/trtRequirements.txt
16+
COPY tensorrt/requirements.txt /tmp/pipReqs/trtRequirements.txt
1517
RUN pip install --disable-pip-version-check -U -r jocRequirements.txt -r trtRequirements.txt
1618

1719

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

33
# Constructs a docker image containing dependencies for execution of JASPER through TRT
4-
echo "docker build . -f ./trt/Dockerfile -t jasper:trt6"
5-
docker build . -f ./trt/Dockerfile -t jasper:trt6
4+
echo "docker build . -f ./tensorrt/Dockerfile -t jasper:trt6"
5+
docker build . -f ./tensorrt/Dockerfile -t jasper:trt6

0 commit comments

Comments
 (0)