Skip to content

Commit

Permalink
Better handling of python versions for client docker build (triton-in…
Browse files Browse the repository at this point in the history
  • Loading branch information
deadeyegoodwin authored Aug 27, 2019
1 parent 98e472b commit 6988077
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.QA
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ COPY --from=cbe /workspace/qa/ qa/

# Remove CI tests that are meant to run only on build image and
# install the tensorrtserver python client APIs.
RUN rm -fr qa/L0_copyrights qa/L0_unit_test && \
RUN rm -fr qa/L0_copyrights && \
pip install --upgrade qa/pkgs/tensorrtserver-*.whl

ENV LD_LIBRARY_PATH /opt/tensorrtserver/qa/clients:${LD_LIBRARY_PATH}
28 changes: 18 additions & 10 deletions Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ ARG UBUNTU_VERSION=18.04

FROM ubuntu:${UBUNTU_VERSION}

# Default to use Python3. Allowed values are "2" and "3".
ARG PYVER=3

# Ensure apt-get won't prompt for selecting options
ENV DEBIAN_FRONTEND=noninteractive
ENV PYVER=$PYVER

# install platform specific packages
RUN if [ $(cat /etc/os-release | grep 'VERSION_ID="16.04"' | wc -l) -ne 0 ]; then \
Expand All @@ -46,7 +50,8 @@ RUN if [ $(cat /etc/os-release | grep 'VERSION_ID="16.04"' | wc -l) -ne 0 ]; the
exit 1; \
fi

RUN apt-get update && \
RUN PYSFX=`[ "$PYVER" != "2" ] && echo "$PYVER" || echo ""` && \
apt-get update && \
apt-get install -y --no-install-recommends \
software-properties-common \
autoconf \
Expand All @@ -60,14 +65,14 @@ RUN apt-get update && \
libssl-dev \
libtool \
pkg-config \
python \
python-dev

RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py
python${PYSFX} \
python${PYSFX}-pip \
python${PYSFX}-dev && \
pip${PYSFX} install --upgrade wheel setuptools grpcio-tools

RUN pip install --upgrade setuptools grpcio-tools
# Build expects "python" executable (not python3).
RUN rm -f /usr/bin/python && \
ln -s /usr/bin/python$PYVER /usr/bin/python

# Build the client library and examples
WORKDIR /workspace
Expand All @@ -88,8 +93,11 @@ COPY qa/images/mug.jpg images/mug.jpg

# Install the dependencies needed to run the client examples. These
# are not needed for building but including them allows this image to
# be used to run the client examples.
RUN pip install --upgrade install/python/tensorrtserver-*.whl numpy pillow
# be used to run the client examples. The special upgrade and handling
# of pip is needed to get numpy to install correctly with python2 on
# ubuntu 16.04.
RUN python -m pip install --user --upgrade pip && \
python -m pip install --upgrade install/python/tensorrtserver-*.whl numpy pillow

ENV PATH //workspace/install/bin:${PATH}
ENV LD_LIBRARY_PATH /workspace/install/lib:${LD_LIBRARY_PATH}
11 changes: 8 additions & 3 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ the Ubuntu version that you want the client library built
for. Supported values for *<ver>* are 16.04 and 18.04, with 16.04
being the default.

The generated Python wheel file works with both Python2 and Python3,
but you can control which version of Python (and pip) are used to
generate the wheel file by editing PYVER in Dockerfile.client. The
default is Python3 and pip3.

After the build completes the tensorrtserver_client docker image will
contain the built client libraries and examples, and will also be
configured with all the dependencies required to run those examples
Expand Down Expand Up @@ -274,7 +279,7 @@ directory::
The Python version of the application accepts the same command-line
arguments::

$ python3 image_client.py -m resnet50_netdef -s INCEPTION qa/images/mug.jpg
$ python image_client.py -m resnet50_netdef -s INCEPTION qa/images/mug.jpg
Request 0, batch size 1
Image '../qa/images/mug.jpg':
504 (COFFEE MUG) = 0.778078556061
Expand Down Expand Up @@ -388,7 +393,7 @@ directory::
The Python version of the application accepts the same command-line
arguments::

$ python3 ensemble_image_client.py qa/images/mug.jpg
$ python ensemble_image_client.py qa/images/mug.jpg
Image 'qa/images/mug.jpg':
504 (COFFEE MUG) = 0.778078556061

Expand Down Expand Up @@ -616,7 +621,7 @@ download it as described in
:ref:`section-getting-the-client-libraries-and-examples` and install
the tensorrtserver whl, then::

$ python3 simple_client.py
$ python simple_client.py

String Datatype
^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ example model repository for an image from the qa/images directory::
The Python version of the application accepts the same command-line
arguments::

$ python3 /tmp/client/python/image_client.py -m resnet50_netdef -s INCEPTION images/mug.jpg
$ python /tmp/client/python/image_client.py -m resnet50_netdef -s INCEPTION images/mug.jpg
Request 0, batch size 1
Image '../qa/images/mug.jpg':
504 (COFFEE MUG) = 0.778078556061
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function main() {

pushd "${WHLDIR}"
echo $(date) : "=== Building wheel"
VERSION=$VERSION python setup.py bdist_wheel
VERSION=$VERSION python${PYVER} setup.py bdist_wheel
mkdir -p "${DEST}"
cp dist/* "${DEST}"
popd
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/ensemble_image_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/grpc_image_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/image_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/simple_callback_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/simple_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/simple_sequence_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion src/clients/python/simple_string_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
Expand Down

0 comments on commit 6988077

Please sign in to comment.