Skip to content
Merged
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 48 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ else()
endif()

# Look for installed Torchvision package in lib paths
if(TRITON_PYTORCH_ENABLE_TORCHVISION AND NOT EXISTS "${TRITON_PYTORCH_LIB_PATHS}/libtorchvision.so.1")
message(WARNING "TRITON_PYTORCH_ENABLE_TORCHVISION is on, but TRITON_PYTORCH_LIB_PATHS does not contain Torchvision package")
if(TRITON_PYTORCH_ENABLE_TORCHVISION)
if(${RHEL_BUILD})
if(NOT EXISTS "${TRITON_PYTORCH_LIB_PATHS}/libtorchvision.so")
message(WARNING "TRITON_PYTORCH_ENABLE_TORCHVISION is on, but TRITON_PYTORCH_LIB_PATHS does not contain Torchvision package")
endif()
else()
if(NOT EXISTS "${TRITON_PYTORCH_LIB_PATHS}/libtorchvision.so.1")
message(WARNING "TRITON_PYTORCH_ENABLE_TORCHVISION is on, but TRITON_PYTORCH_LIB_PATHS does not contain Torchvision package")
endif()
endif()
endif()
endif()

Expand Down Expand Up @@ -162,10 +170,17 @@ set(PT_LIBS
)

if (${TRITON_PYTORCH_ENABLE_TORCHVISION})
set(PT_LIBS
${PT_LIBS}
"libtorchvision.so.1"
)
if(${RHEL_BUILD})
set(PT_LIBS
${PT_LIBS}
"libtorchvision.so"
)
else()
set(PT_LIBS
${PT_LIBS}
"libtorchvision.so.1"
)
endif()
endif() # TRITON_PYTORCH_ENABLE_TORCHVISION

if (${TRITON_PYTORCH_ENABLE_TORCHTRT})
Expand Down Expand Up @@ -215,9 +230,21 @@ set(OPENCV_LIBS
"libopencv_calib3d.so"
"libopencv_flann.so"
"libopencv_features2d.so"
"libpng16.so"
"libjpeg.so"
)
if(${RHEL_BUILD})
set(OPENCV_LIBS
${OPENCV_LIBS}
"libjpeg.so.62" # RHEL uses only .so.62 version
"libpng16.so.16" # RHEL uses .so.16 version
)
else()
set(OPENCV_LIBS
${OPENCV_LIBS}
"libjpeg.so" # Non-RHEL uses both .so and .so.62
"libjpeg.so.62"
"libpng16.so"
)
endif()

# The patchelf commands ensure the MKL libraries are loaded correctly during runtime
# Without these, the framework/backend complains of missing libraries / symbols and
Expand Down Expand Up @@ -249,7 +276,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libcaffe2_nvrtc.so libcaffe2_nvrtc.so
# TODO: Revisit when not needed by making it part of cuda base container.
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/cuda/lib64/libcusparseLt.so libcusparseLt.so;
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHVISION} = 'ON' ]; then docker cp -a -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libtorchvision.so.1 libtorchvision.so.1; fi"
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHVISION} = 'ON' ]; then if [ ${RHEL_BUILD} = 'ON' ]; then docker cp -a -L pytorch_backend_ptlib:/usr/local/lib64/libtorchvision.so libtorchvision.so; else docker cp -a -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libtorchvision.so.1 libtorchvision.so.1; fi; fi"
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHVISION} = 'ON' ]; then docker cp pytorch_backend_ptlib:/opt/pytorch/vision/torchvision/csrc include/torchvision/torchvision; fi"
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHTRT} = 'ON' ]; then docker cp pytorch_backend_ptlib:/usr/local/lib/python3.12/dist-packages/torch_tensorrt/lib/libtorchtrt_runtime.so libtorchtrt_runtime.so; fi"
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch_tensorrt/bin/torchtrtc torchtrtc || echo "error ignored..." || true
Expand All @@ -265,10 +292,8 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libopencv_calib3d.so libopencv_calib3d.so
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libopencv_features2d.so libopencv_features2d.so
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libopencv_flann.so libopencv_flann.so
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/lib/libjpeg.so.62 libjpeg.so.62
COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libpng16.so.16.43.0 libpng16.so"
COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libjpeg.so.8.2.2 libjpeg.so"
COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:/usr/local/lib/libjpeg.so.62 libjpeg.so.62 || docker cp pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libjpeg.so.62 libjpeg.so.62"
COMMAND /bin/sh -c "if [ ${RHEL_BUILD} = 'ON' ]; then docker cp -L pytorch_backend_ptlib:/usr/lib64/libjpeg.so.62 libjpeg.so.62; else docker cp -L pytorch_backend_ptlib:/usr/local/lib/libjpeg.so.62 libjpeg.so.62 && docker cp pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libjpeg.so.8.2.2 libjpeg.so; fi;"
COMMAND /bin/sh -c "if [ ${RHEL_BUILD} = 'ON' ]; then docker cp -L pytorch_backend_ptlib:/usr/lib64/libpng16.so.16 libpng16.so.16; else docker cp -L pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libpng16.so libpng16.so; fi;"
COMMAND /bin/sh -c "if [ -f libmkl_def.so.1 ]; then patchelf --add-needed libmkl_gnu_thread.so.1 libmkl_def.so.1; fi"
COMMAND /bin/sh -c "if [ -f libmkl_def.so.1 ]; then patchelf --add-needed libmkl_core.so.1 libmkl_def.so.1; fi"
COMMAND /bin/sh -c "if [ -f libmkl_avx2.so.1 ]; then patchelf --add-needed libmkl_gnu_thread.so.1 libmkl_avx2.so.1; fi"
Expand All @@ -279,7 +304,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
COMMAND /bin/sh -c "if [ -f libmkl_vml_def.so.1 ]; then patchelf --add-needed libmkl_intel_thread.so.1 libmkl_vml_def.so.1; fi"
COMMAND /bin/sh -c "if [ -f libmkl_vml_def.so.1 ]; then patchelf --add-needed libmkl_core.so.1 libmkl_vml_def.so.1; fi"
COMMAND /bin/sh -c "if [ -f libmkl_intel_thread.so.1 ]; then patchelf --add-needed libmkl_intel_lp64.so.1 libmkl_intel_thread.so.1; fi"
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHVISION} = 'ON' ]; then ln -s libtorchvision.so.1 libtorchvision.so; fi"
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHVISION} = 'ON' ]; then if [ ${RHEL_BUILD} = 'OFF' ]; then ln -s libtorchvision.so.1 libtorchvision.so; fi; fi;"
COMMAND docker rm pytorch_backend_ptlib
COMMENT "Extracting pytorch and torchvision libraries and includes from ${TRITON_PYTORCH_DOCKER_IMAGE}"
VERBATIM
Expand Down Expand Up @@ -382,9 +407,15 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
set(TRITON_PYTORCH_LIBS "${CMAKE_CURRENT_BINARY_DIR}/libtorch.so")

if (${TRITON_PYTORCH_ENABLE_TORCHVISION})
set(TRITON_PYTORCH_LIBS
${TRITON_PYTORCH_LIBS}
"${CMAKE_CURRENT_BINARY_DIR}/libtorchvision.so.1")
if(${RHEL_BUILD})
set(TRITON_PYTORCH_LIBS
${TRITON_PYTORCH_LIBS}
"${CMAKE_CURRENT_BINARY_DIR}/libtorchvision.so")
else()
set(TRITON_PYTORCH_LIBS
${TRITON_PYTORCH_LIBS}
"${CMAKE_CURRENT_BINARY_DIR}/libtorchvision.so.1")
endif()
endif() # TRITON_PYTORCH_ENABLE_TORCHVISION

if (${TRITON_PYTORCH_ENABLE_TORCHTRT})
Expand Down