Skip to content

Commit

Permalink
Additional pytorch build related cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderHam committed Jan 12, 2021
1 parent 1d22041 commit 815c925
Showing 1 changed file with 3 additions and 64 deletions.
67 changes: 3 additions & 64 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,41 +515,6 @@ def create_dockerfile_buildbase(ddir, dockerfile_name, argmap, backends):
apt-get update && \
apt-get install -y --no-install-recommends \
cmake-data=3.18.4-0kitware1ubuntu20.04.1 cmake=3.18.4-0kitware1ubuntu20.04.1
'''
if 'pytorch' in backends:
df += '''
# LibTorch and Torchvision headers and libraries
COPY --from=tritonserver_pytorch \
/opt/conda/lib/python3.8/site-packages/torch/lib/libc10.so \
/opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch \
/opt/conda/lib/python3.8/site-packages/torch/lib/libc10_cuda.so \
/opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libmkl_core.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libmkl_gnu_thread.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libmkl_intel_lp64.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libmkl_intel_thread.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libmkl_def.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libmkl_avx2.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/libiomp5.so /opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/python3.8/site-packages/torch/include \
/opt/tritonserver/include/torch
COPY --from=tritonserver_pytorch /opt/conda/lib/python3.8/site-packages/torch/lib/libtorch.so \
/opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so \
/opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/conda/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so \
/opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/pytorch/vision/torchvision/csrc \
/opt/tritonserver/include/torchvision/torchvision/
COPY --from=tritonserver_pytorch /opt/pytorch/vision/build/libtorchvision.so \
/opt/tritonserver/backends/pytorch/
COPY --from=tritonserver_pytorch /opt/pytorch/pytorch/LICENSE \
/opt/tritonserver/backends/pytorch/
RUN cd /opt/tritonserver/backends/pytorch && \
for i in `find . -mindepth 1 -maxdepth 1 -type f -name '*\.so*'`; do \
patchelf --set-rpath '$ORIGIN' $i; \
done
'''
if 'onnxruntime' in backends:
df += '''
Expand Down Expand Up @@ -750,10 +715,6 @@ def create_dockerfile(ddir, dockerfile_name, argmap, backends):
COPY --chown=1000:1000 VERSION .
COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/bin/tritonserver bin/
COPY --chown=1000:1000 --from=tritonserver_build /tmp/tritonbuild/install/lib/libtritonserver.so lib/
'''
if 'pytorch' in backends:
df += '''
COPY --chown=1000:1000 --from=tritonserver_build /opt/tritonserver/backends/pytorch backends/pytorch
'''
if 'onnxruntime' in backends:
df += '''
Expand Down Expand Up @@ -821,16 +782,6 @@ def container_build(backends, images):
base_image,
}

# If building the pytorch backend then need to include pytorch in
# buildbase image.
if 'pytorch' in backends:
if 'pytorch' in images:
pytorch_image = images['pytorch']
else:
pytorch_image = 'nvcr.io/nvidia/pytorch:{}-py3'.format(
FLAGS.upstream_container_version)
dockerfileargmap['PYTORCH_IMAGE'] = pytorch_image

# If building the ORT backend then need to include ORT in
# buildbase image.
if 'onnxruntime' in backends:
Expand All @@ -844,11 +795,9 @@ def container_build(backends, images):
FLAGS.version][3]

cachefrommap = [
'tritonserver_pytorch', 'tritonserver_pytorch_cache0',
'tritonserver_pytorch_cache1', 'tritonserver_onnx',
'tritonserver_onnx_cache0', 'tritonserver_onnx_cache1',
'tritonserver_buildbase', 'tritonserver_buildbase_cache0',
'tritonserver_buildbase_cache1'
'tritonserver_onnx', 'tritonserver_onnx_cache0',
'tritonserver_onnx_cache1', 'tritonserver_buildbase',
'tritonserver_buildbase_cache0', 'tritonserver_buildbase_cache1'
]

cachefromargs = ['--cache-from={}'.format(k) for k in cachefrommap]
Expand All @@ -865,16 +814,6 @@ def container_build(backends, images):
# does caching with multi-stage images, we must build each
# stage separately to make sure it is cached.

# PyTorch
if 'pytorch' in backends:
p = subprocess.Popen(commonargs + cachefromargs + [
'-t', 'tritonserver_pytorch', '--target',
'tritonserver_pytorch', '.'
])
p.wait()
fail_if(p.returncode != 0,
'docker build tritonserver_pytorch failed')

# ONNX Runtime
if 'onnxruntime' in backends:
p = subprocess.Popen(commonargs + cachefromargs + [
Expand Down

0 comments on commit 815c925

Please sign in to comment.