Skip to content

Commit e3244bc

Browse files
pvijayakrishmc-nv
andauthored
Fix RHEL build
* Update the RHEL library path * Remove the ternsary operator in cmake * Update the libpng and libjpeg paths * Update the libpng and libjpeg paths * Add -L option for docker cp * Add missing space * Update the libjpeg installation for rhel * Update the libpng installation for rhel * Update changes to opencv path * Revert "Update changes to opencv path" This reverts commit f511258. * Remove commented line * Updating the opencv libraries for non RHEL build * Using find_library to verify Torchvision package find_library() function in CMake is used to search for a library in specific directories and return its path if found. Co-authored-by: Misha Chornyi <[email protected]> * Remove incorrect end if The end_if needs to be removed as the associated if statement was removed in a previous commit. * Use generator expressions Use generator expressions instead of if-else. * Fix typo * Fix typo * Update RHEL_BUILD used in condition * fixing variable expansion * Remove trailing white space. --------- Co-authored-by: Misha Chornyi <[email protected]>
1 parent cd2dc94 commit e3244bc

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

CMakeLists.txt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ else()
7878
endif()
7979

8080
# Look for installed Torchvision package in lib paths
81-
if(TRITON_PYTORCH_ENABLE_TORCHVISION AND NOT EXISTS "${TRITON_PYTORCH_LIB_PATHS}/libtorchvision.so.1")
81+
find_library( LIBTORCHVISION libtorchvision.so libtorchvision.so.1 PATHS ${TRITON_PYTORCH_LIB_PATHS} )
82+
if(NOT ${LIBTORCHVISION})
8283
message(WARNING "TRITON_PYTORCH_ENABLE_TORCHVISION is on, but TRITON_PYTORCH_LIB_PATHS does not contain Torchvision package")
83-
endif()
84+
endif(NOT ${LIBTORCHVISION})
8485
endif()
8586

8687
# Python.h needed by torch headers.
@@ -164,7 +165,7 @@ set(PT_LIBS
164165
if (${TRITON_PYTORCH_ENABLE_TORCHVISION})
165166
set(PT_LIBS
166167
${PT_LIBS}
167-
"libtorchvision.so.1"
168+
$<IF:$<BOOL:${RHEL_BUILD}>,libtorchvision.so,libtorchvision.so.1>
168169
)
169170
endif() # TRITON_PYTORCH_ENABLE_TORCHVISION
170171

@@ -215,8 +216,8 @@ set(OPENCV_LIBS
215216
"libopencv_calib3d.so"
216217
"libopencv_flann.so"
217218
"libopencv_features2d.so"
218-
"libpng16.so"
219-
"libjpeg.so"
219+
$<IF:$<BOOL:${RHEL_BUILD}>,libjpeg.so.62,libjpeg.so>
220+
$<IF:$<BOOL:${RHEL_BUILD}>,libpng16.so.16,libpng16.so>
220221
)
221222

222223
# The patchelf commands ensure the MKL libraries are loaded correctly during runtime
@@ -249,7 +250,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
249250
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libcaffe2_nvrtc.so libcaffe2_nvrtc.so
250251
# TODO: Revisit when not needed by making it part of cuda base container.
251252
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/cuda/lib64/libcusparseLt.so libcusparseLt.so;
252-
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"
253+
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"
253254
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"
254255
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"
255256
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch_tensorrt/bin/torchtrtc torchtrtc || echo "error ignored..." || true
@@ -265,10 +266,8 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
265266
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libopencv_calib3d.so libopencv_calib3d.so
266267
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libopencv_features2d.so libopencv_features2d.so
267268
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libopencv_flann.so libopencv_flann.so
268-
COMMAND docker cp -L pytorch_backend_ptlib:/usr/local/lib/libjpeg.so.62 libjpeg.so.62
269-
COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libpng16.so.16.43.0 libpng16.so"
270-
COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:/usr/lib/${LIBS_ARCH}-linux-gnu/libjpeg.so.8.2.2 libjpeg.so"
271-
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"
269+
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;"
270+
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;"
272271
COMMAND /bin/sh -c "if [ -f libmkl_def.so.1 ]; then patchelf --add-needed libmkl_gnu_thread.so.1 libmkl_def.so.1; fi"
273272
COMMAND /bin/sh -c "if [ -f libmkl_def.so.1 ]; then patchelf --add-needed libmkl_core.so.1 libmkl_def.so.1; fi"
274273
COMMAND /bin/sh -c "if [ -f libmkl_avx2.so.1 ]; then patchelf --add-needed libmkl_gnu_thread.so.1 libmkl_avx2.so.1; fi"
@@ -279,7 +278,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
279278
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"
280279
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"
281280
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"
282-
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_ENABLE_TORCHVISION} = 'ON' ]; then ln -s libtorchvision.so.1 libtorchvision.so; fi"
281+
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;"
283282
COMMAND docker rm pytorch_backend_ptlib
284283
COMMENT "Extracting pytorch and torchvision libraries and includes from ${TRITON_PYTORCH_DOCKER_IMAGE}"
285284
VERBATIM
@@ -383,8 +382,8 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
383382

384383
if (${TRITON_PYTORCH_ENABLE_TORCHVISION})
385384
set(TRITON_PYTORCH_LIBS
386-
${TRITON_PYTORCH_LIBS}
387-
"${CMAKE_CURRENT_BINARY_DIR}/libtorchvision.so.1")
385+
${TRITON_PYTORCH_LIBS}
386+
"${CMAKE_CURRENT_BINARY_DIR}/$<IF:$<BOOL:${RHEL_BUILD}>,libtorchvision.so,libtorchvision.so.1>")
388387
endif() # TRITON_PYTORCH_ENABLE_TORCHVISION
389388

390389
if (${TRITON_PYTORCH_ENABLE_TORCHTRT})

0 commit comments

Comments
 (0)