Skip to content

Commit

Permalink
Install repoagents into /opt/tritonserver for container build (triton…
Browse files Browse the repository at this point in the history
  • Loading branch information
deadeyegoodwin authored Feb 11, 2021
1 parent 17e83f0 commit 78c2082
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
8 changes: 3 additions & 5 deletions Dockerfile.QA
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -68,7 +68,7 @@ RUN mkdir -p inception_graphdef/1 && \
cp /tmp/tritonbuild/tritonserver/build/test-util/install/lib/libimagepreprocess.so \
image_preprocess_nhwc_299x299x3_inception/1/. && \
mkdir -p preprocess_inception_ensemble/1

# Update the qa/ directory with test executables, models, etc.
WORKDIR /workspace
RUN mkdir -p qa/common && \
Expand Down Expand Up @@ -255,8 +255,6 @@ RUN mkdir -p qa/L0_decoupled/models/simple_repeat/1 && \
mkdir -p qa/L0_decoupled/models/sequence_repeat/1 && \
mkdir -p qa/L0_decoupled/models/repeat_square/1 && \
mkdir -p qa/L0_decoupled/models/nested_square/1
RUN cp /tmp/tritonbuild/install/repoagents/checksum/libtritonrepoagent_checksum.so \
qa/L0_repoagent_checksum/models/identity_int32/.
RUN mkdir -p qa/L0_repoagent_checksum/models/identity_int32/1 && \
cp /tmp/tritonbuild/install/backends/identity/libtriton_identity.so \
qa/L0_repoagent_checksum/models/identity_int32/1/.
Expand Down Expand Up @@ -319,7 +317,7 @@ RUN rm -f /usr/bin/python && \
ln -s /usr/bin/python3 /usr/bin/python

RUN pip3 install --upgrade wheel setuptools && \
pip3 install --upgrade numpy pillow future grpcio requests gsutil awscli six boofuzz grpcio-channelz azure-cli
pip3 install --upgrade numpy pillow future grpcio requests gsutil awscli six boofuzz grpcio-channelz azure-cli

# need protoc-gen-go to generate go specific gRPC modules
RUN go get github.com/golang/protobuf/protoc-gen-go && \
Expand Down
26 changes: 18 additions & 8 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
NONCORE_BACKENDS = [
'tensorflow1', 'tensorflow2', 'onnxruntime', 'python', 'dali', 'pytorch'
]
EXAMPLE_REPOAGENTS = ['checksum',]
EXAMPLE_REPOAGENTS = [
'checksum',
]
FLAGS = None


Expand Down Expand Up @@ -358,8 +360,10 @@ def pytorch_cmake_args(images):
def onnxruntime_cmake_args():
cargs = [
'-DTRITON_ENABLE_ONNXRUNTIME_TENSORRT=ON',
'-DTRITON_BUILD_ONNXRUNTIME_VERSION={}'.format(TRITON_VERSION_MAP[FLAGS.version][2]),
'-DTRITON_BUILD_CONTAINER_VERSION={}'.format(TRITON_VERSION_MAP[FLAGS.version][1])
'-DTRITON_BUILD_ONNXRUNTIME_VERSION={}'.format(
TRITON_VERSION_MAP[FLAGS.version][2]),
'-DTRITON_BUILD_CONTAINER_VERSION={}'.format(
TRITON_VERSION_MAP[FLAGS.version][1])
]

if TRITON_VERSION_MAP[FLAGS.version][3] is not None:
Expand Down Expand Up @@ -527,7 +531,7 @@ def create_dockerfile_build(ddir, dockerfile_name, argmap, backends):
dfile.write(df)


def create_dockerfile(ddir, dockerfile_name, argmap, backends):
def create_dockerfile(ddir, dockerfile_name, argmap, backends, repoagents):
df = '''
#
# Multistage build.
Expand Down Expand Up @@ -618,6 +622,11 @@ def create_dockerfile(ddir, dockerfile_name, argmap, backends):
'''
break

if len(repoagents) > 0:
df += '''
COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/repoagents repoagents
'''

df += '''
# Extra defensive wiring for CUDA Compat lib
RUN ln -sf ${{_CUDA_COMPAT_PATH}}/lib.real ${{_CUDA_COMPAT_PATH}}/lib \
Expand All @@ -640,7 +649,7 @@ def create_dockerfile(ddir, dockerfile_name, argmap, backends):
dfile.write(df)


def container_build(backends, images):
def container_build(images, backends, repoagents):
# The build and install directories within the container.
build_dir = os.path.join(os.sep, 'tmp', 'tritonbuild')
install_dir = os.path.join(os.sep, 'tmp', 'tritonbuild', 'install')
Expand Down Expand Up @@ -811,7 +820,7 @@ def container_build(backends, images):
# bother to create the base image for windows.
if platform.system() != 'Windows':
create_dockerfile(FLAGS.build_dir, 'Dockerfile', dockerfileargmap,
backends)
backends, repoagents)
p = subprocess.Popen([
'docker', 'build', '-f',
os.path.join(FLAGS.build_dir, 'Dockerfile')
Expand Down Expand Up @@ -1066,7 +1075,7 @@ def container_build(backends, images):
# build within a build container and then from that create a
# tritonserver container holding the results of the build.
if not FLAGS.no_container_build:
container_build(backends, images)
container_build(images, backends, repoagents)
sys.exit(0)

# If there is a container pre-build command assume this invocation
Expand Down Expand Up @@ -1152,7 +1161,8 @@ def container_build(backends, images):
repoagent_cmake_args(images, components, ra, repo_install_dir))
makeinstall(repo_build_dir)

repoagent_install_dir = os.path.join(FLAGS.install_dir, 'repoagents', ra)
repoagent_install_dir = os.path.join(FLAGS.install_dir, 'repoagents',
ra)
rmdir(repoagent_install_dir)
mkdir(repoagent_install_dir)
cpdir(os.path.join(repo_install_dir, 'repoagents', ra),
Expand Down
23 changes: 9 additions & 14 deletions src/core/triton_repo_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,10 @@ TritonRepoAgentManager::CreateAgent(
auto& singleton_manager = Singleton();
std::lock_guard<std::mutex> lock(singleton_manager.mu_);

// Get the path to the agent shared library. Search path is model
// directory, global agent directory. FIXME expose global path as
// Triton option
// Get the path to the agent shared library. Search path is global
// agent directory. FIXME expose global path as Triton option
const std::vector<std::string> search_paths = {
model_dir, singleton_manager.global_search_path_};
JoinPath({singleton_manager.global_search_path_, agent_name})};

std::string agent_libname = TritonRepoAgentLibraryName(agent_name);
std::string libpath;
Expand All @@ -389,10 +388,9 @@ TritonRepoAgentManager::CreateAgent(

if (libpath.empty()) {
return Status(
Status::Code::INVALID_ARG, "unable to find '" + agent_libname +
"' for repo agent '" + agent_name +
"', searched: " + model_dir + ", " +
singleton_manager.global_search_path_);
Status::Code::INVALID_ARG,
"unable to find '" + agent_libname + "' for repo agent '" + agent_name +
"', searched: " + singleton_manager.global_search_path_);
}

const auto& itr = singleton_manager.agent_map_.find(libpath);
Expand All @@ -417,16 +415,13 @@ TritonRepoAgentManager::CreateAgent(

Status
TritonRepoAgentManager::AgentState(
std::unique_ptr<
std::unordered_map<std::string, std::string>>*
agent_state)
std::unique_ptr<std::unordered_map<std::string, std::string>>* agent_state)
{
auto& singleton_manager = Singleton();
std::lock_guard<std::mutex> lock(singleton_manager.mu_);

std::unique_ptr<std::unordered_map<std::string, std::string>>
agent_state_map(
new std::unordered_map<std::string, std::string>);
std::unique_ptr<std::unordered_map<std::string, std::string>> agent_state_map(
new std::unordered_map<std::string, std::string>);
for (const auto& agent_pair : singleton_manager.agent_map_) {
auto& libpath = agent_pair.first;
auto agent = agent_pair.second.lock();
Expand Down

0 comments on commit 78c2082

Please sign in to comment.