Skip to content

Commit

Permalink
Fix client build for TRITON_ENABLE_GPU=OFF (triton-inference-server#1704
Browse files Browse the repository at this point in the history
)

* Fix client build for TRITON_ENABLE_GPU=OFF

* Update docs
  • Loading branch information
deadeyegoodwin authored Jun 25, 2020
1 parent 9846916 commit e6864d7
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Dockerfile.centos_client
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ COPY build build
COPY src/clients src/clients
COPY src/core src/core

RUN cd build && \
RUN mkdir builddir && cd builddir && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/workspace/install \
-DTRITON_ENABLE_GRPC=ON \
-DTRITON_ENABLE_HTTP=ON && \
-DTRITON_ENABLE_HTTP=ON ../build && \
make -j16 client
RUN cd install && \
export VERSION=`cat /workspace/VERSION` && \
tar zcf /workspace/v$VERSION.clients.tar.gz *

# For CI testing need to install a test script.
COPY qa/L0_client_tar/test.sh /tmp/test.sh
COPY qa/L0_client/test.sh /tmp/test.sh

# Install an image needed by the quickstart and other documentation.
COPY qa/images/mug.jpg images/mug.jpg
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ COPY build build
COPY src/clients src/clients
COPY src/core src/core

RUN cd build && \
RUN mkdir builddir && cd builddir && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=/workspace/install \
-DTRITON_ENABLE_GRPC=ON \
-DTRITON_ENABLE_HTTP=ON && \
-DTRITON_ENABLE_HTTP=ON ../build && \
make -j16 client
RUN cd install && \
export VERSION=`cat /workspace/VERSION` && \
tar zcf /workspace/v$VERSION.clients.tar.gz *

# For CI testing need to install a test script.
COPY qa/L0_client_tar/test.sh /tmp/test.sh
COPY qa/L0_client/test.sh /tmp/test.sh

# Install an image needed by the quickstart and other documentation.
COPY qa/images/mug.jpg images/mug.jpg
Expand Down
19 changes: 15 additions & 4 deletions docs/client_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ For Ubuntu, the dependencies and how to install them can be found in
Dockerfile.client. Also note that the dependency name may be different
depending on the version of the system.

To build on Ubuntu, change to the build/ directory and run the
following to configure and build::
To build on Ubuntu, run the following to configure and build::

$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release
$ mkdir builddir && cd builddir
$ cmake -DCMAKE_BUILD_TYPE=Release ../build
$ make -j8 client

If you want to build a version of the client libraries and examples
that does not include the CUDA shared memory support, use the
following cmake configuration::

$ cmake -DTRITON_ENABLE_GPU=OFF -DTRITON_ENABLE_METRICS_GPU=OFF -DCMAKE_BUILD_TYPE=Release ../build

When the build completes the libraries can be found in
client/install/lib, the corresponding headers in
client/install/include, and the Python wheel files in
Expand Down Expand Up @@ -155,6 +160,12 @@ are using Microsoft Visual Studio, you should do the following::
> cmake -G"Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release
> MSBuild.exe client.vcxproj -p:Configuration=Release

If you want to build a version of the client libraries and examples
that does not include the CUDA shared memory support, use the
following cmake configuration::

> cmake -G"Visual Studio 16 2019" -DTRITON_ENABLE_GPU=OFF -DTRITON_ENABLE_METRICS_GPU=OFF -DCMAKE_BUILD_TYPE=Release

When the build completes the libraries can be found in
client\\install\\lib, the corresponding headers in
client\\install\\include, and the Python wheel files in
Expand Down
20 changes: 18 additions & 2 deletions qa/L0_client_tar/test.sh → qa/L0_client/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

CLIENT_LOG=client.log

# Install the tar file
rm -fr triton_client
mkdir triton_client
Expand Down Expand Up @@ -65,6 +63,24 @@ for l in $WHLS; do
fi
done

# This test is running in a non-NVIDIA docker so we can configure the
# build without GPUs and make sure it works correctly.
cd /workspace/builddir && rm -fr client ../install/*
cmake -DTRITON_ENABLE_GPU=OFF -DTRITON_ENABLE_METRICS_GPU=OFF ../build
make -j16 client

CUDAFILES=`find /workspace/builddir/client/install -name *cuda* | wc -l`
if [ "$CUDAFILES" != "0" ]; then
echo -e "*** unexpected CUDA files in TRITON_ENABLE_GPU=OFF build\n"
RET=1
fi

SHMFILES=`find /workspace/builddir/client/install -name *shm* | wc -l`
if [ "$SHMFILES" != "7" ]; then
echo -e "*** expected 7 SHM files in TRITON_ENABLE_GPU=OFF build, got $SHMFILES\n"
RET=1
fi

if [ $RET -eq 0 ]; then
echo -e "\n***\n*** Test Passed\n***"
else
Expand Down
1 change: 1 addition & 0 deletions src/clients/c++/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ else()
target_link_libraries(
simple_http_shm_client
PRIVATE TRITON::httpclient_static
PRIVATE rt
)
install(
TARGETS simple_http_shm_client
Expand Down
4 changes: 2 additions & 2 deletions src/clients/c++/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if(${TRITON_ENABLE_GRPC})

set(
REQUEST_HDRS
grpc_client.h common.h
grpc_client.h common.h ipc.h
)

add_library(
Expand Down Expand Up @@ -167,7 +167,7 @@ if(${TRITON_ENABLE_HTTP})

set(
REQUEST_HDRS
http_client.h common.h cencode.h
http_client.h common.h ipc.h cencode.h
)

add_library(
Expand Down
3 changes: 1 addition & 2 deletions src/clients/c++/library/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

/// \file

#include "src/core/constants.h"

#include <algorithm>
#include <chrono>
#include <condition_variable>
Expand All @@ -41,6 +39,7 @@
#include <string>
#include <thread>
#include <vector>
#include "src/core/constants.h"

namespace nvidia { namespace inferenceserver { namespace client {

Expand Down
9 changes: 1 addition & 8 deletions src/clients/c++/library/grpc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,11 @@

#include <queue>
#include "src/clients/c++/library/common.h"
#include "src/clients/c++/library/ipc.h"
#include "src/core/constants.h"
#include "src/core/grpc_service.grpc.pb.h"
#include "src/core/model_config.pb.h"

#ifdef TRITON_ENABLE_GPU
#include <cuda_runtime_api.h>
#else
struct cudaIpcMemHandle_t {
};
#endif // TRITON_ENABLE_GPU


namespace nvidia { namespace inferenceserver { namespace client {

/// The key-value map type to be included in the request
Expand Down
8 changes: 1 addition & 7 deletions src/clients/c++/library/http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@
#include <map>
#include <memory>
#include "src/clients/c++/library/common.h"

#ifdef TRITON_ENABLE_GPU
#include <cuda_runtime_api.h>
#else
struct cudaIpcMemHandle_t {
};
#endif // TRITON_ENABLE_GPU
#include "src/clients/c++/library/ipc.h"

namespace nvidia { namespace inferenceserver { namespace client {

Expand Down
33 changes: 33 additions & 0 deletions src/clients/c++/library/ipc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once

#ifdef TRITON_ENABLE_GPU
#include <cuda_runtime_api.h>
#else
struct cudaIpcMemHandle_t {
};
#endif // TRITON_ENABLE_GPU
16 changes: 14 additions & 2 deletions src/clients/python/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,18 @@ if(${TRITON_ENABLE_HTTP})
simple_http_string_infer_client.py
simple_http_async_infer_client.py
simple_http_sequence_sync_infer_client.py
simple_http_cudashm_client.py
simple_http_shm_client.py
simple_http_shm_string_client.py
simple_http_model_control.py
DESTINATION python
)
if(${TRITON_ENABLE_GPU})
install(
PROGRAMS
simple_http_cudashm_client.py
DESTINATION python
)
endif() # TRITON_ENABLE_GPU
endif() # TRITON_ENABLE_HTTP

if(${TRITON_ENABLE_GRPC})
Expand All @@ -50,7 +56,6 @@ if(${TRITON_ENABLE_GRPC})
grpc_explicit_int_content_client.py
grpc_explicit_int8_content_client.py
grpc_image_client.py
simple_grpc_cudashm_client.py
simple_grpc_health_metadata.py
simple_grpc_async_infer_client.py
simple_grpc_infer_client.py
Expand All @@ -62,6 +67,13 @@ if(${TRITON_ENABLE_GRPC})
simple_grpc_model_control.py
DESTINATION python
)
if(${TRITON_ENABLE_GPU})
install(
PROGRAMS
simple_grpc_cudashm_client.py
DESTINATION python
)
endif() # TRITON_ENABLE_GPU
endif() # TRITON_ENABLE_GRPC

if(${TRITON_ENABLE_HTTP} OR ${TRITON_ENABLE_GRPC})
Expand Down

0 comments on commit e6864d7

Please sign in to comment.