From 4d41c1bdd8e9049569e11b3fce8b55f000a082ca Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Mon, 4 Nov 2024 18:11:34 -0800 Subject: [PATCH 1/8] Update Python version --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd654c8..37a7f9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,15 +89,15 @@ find_package(Python3 REQUIRED COMPONENTS Development.Module) set(RHEL_BUILD OFF) set(LIB_DIR "lib") set(LIBTORCH_LIBS_PATH "/usr/local/lib") -set(PY_INSTALL_PATH "/usr/local/lib/python3.10/dist-packages") +set(PY_INSTALL_PATH "/usr/local/lib/python3.12/dist-packages") if(LINUX) file(STRINGS "/etc/os-release" DISTRO_ID_LIKE REGEX "ID_LIKE") if(${DISTRO_ID_LIKE} MATCHES "rhel|centos") set(RHEL_BUILD ON) set(LIB_DIR "lib64") - set(PY_INSTALL_PATH "/opt/_internal/cpython-3.10.13/lib/python3.10/site-packages") + set(PY_INSTALL_PATH "/opt/_internal/cpython-3.12.3/lib/python3.12/site-packages") if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") - set(LIBTORCH_LIBS_PATH "/opt/_internal/cpython-3.10.13/lib") + set(LIBTORCH_LIBS_PATH "/opt/_internal/cpython-3.12.3/lib") endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos") endif(LINUX) @@ -249,7 +249,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD}) 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 pytorch_backend_ptlib:/usr/local/${LIB_DIR}/libtorchvision.so libtorchvision.so; 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.10/dist-packages/torch_tensorrt/lib/libtorchtrt_runtime.so libtorchtrt_runtime.so; 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 COMMAND docker cp pytorch_backend_ptlib:/opt/pytorch/pytorch/LICENSE LICENSE.pytorch COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/include include/torch From 762a369b5d3fb810cedbaf4f57de58e912024c1f Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Mon, 4 Nov 2024 19:04:22 -0800 Subject: [PATCH 2/8] Update version for ligpng --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37a7f9b..5d39ed3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,7 +263,7 @@ 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 /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libpng16.so.16.34.0,/usr/lib/${LIBS_ARCH}-linux-gnu/libpng16.so.16.37.0> libpng16.so" + COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libpng16.so.16.34.0,/usr/lib/${LIBS_ARCH}-linux-gnu/libpng16.so.16.43.0> libpng16.so" COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libjpeg.so.62.2.0,/usr/lib/${LIBS_ARCH}-linux-gnu/libjpeg.so.8.2.2> libjpeg.so" 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" From 9b9d34e403e09eaac50d2faa2487f3e186181810 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Tue, 5 Nov 2024 10:19:49 -0800 Subject: [PATCH 3/8] Set proper path --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d39ed3..15e46af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,9 +95,9 @@ if(LINUX) if(${DISTRO_ID_LIKE} MATCHES "rhel|centos") set(RHEL_BUILD ON) set(LIB_DIR "lib64") - set(PY_INSTALL_PATH "/opt/_internal/cpython-3.12.3/lib/python3.12/site-packages") + set(PY_INSTALL_PATH "/opt/_internal/cpython-3.12.1/lib/python3.12/site-packages") if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") - set(LIBTORCH_LIBS_PATH "/opt/_internal/cpython-3.12.3/lib") + set(LIBTORCH_LIBS_PATH "/opt/_internal/cpython-3.12.1/lib") endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos") endif(LINUX) From 3a7d08ddbd17ed1953d3ae6d23259a44bc4eec48 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Wed, 6 Nov 2024 20:04:24 -0800 Subject: [PATCH 4/8] Update pytorch libraryr destination --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15e46af..c1b6a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,8 +263,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 /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libpng16.so.16.34.0,/usr/lib/${LIBS_ARCH}-linux-gnu/libpng16.so.16.43.0> libpng16.so" - COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libjpeg.so.62.2.0,/usr/lib/${LIBS_ARCH}-linux-gnu/libjpeg.so.8.2.2> libjpeg.so" + COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libpng16.so.16.34.0,/usr/local/lib/python3.12/dist-packages/torchvision.libs/libpng16-748299c7.so.16.34.0> libpng16.so" + COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libjpeg.so.62.2.0,/usr/local/lib/python3.12/dist-packages/torchvision.libs/libjpeg-da649728.so.62.2.0> libjpeg.so" 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" @@ -493,6 +493,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD}) COMMAND ln -sf libopencv_flann.so libopencv_flann.so.${OPENCV_VERSION} COMMAND ln -sf libpng16.so libpng16.so.16 COMMAND ln -sf libjpeg.so libjpeg.so.8 + COMMAND ln -sf libjpeg.so libjpeg.so.62 COMMAND ln -sf libcusparseLt.so libcusparseLt.so.0 RESULT_VARIABLE LINK_STATUS WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/backends/pytorch) From 31315c517015a68843706270dcaac71e49c22cd3 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 7 Nov 2024 22:12:10 -0800 Subject: [PATCH 5/8] Update copy file configuration --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1b6a70..8e78a53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,6 +223,7 @@ set(OPENCV_LIBS # in some cases leads to segmentation faults. if (${TRITON_PYTORCH_DOCKER_BUILD}) string(REPLACE ";" " " LIBTORCH_LIBS_STR "${LIBTORCH_LIBS}") + string(RANDOM 8 "abcdefghijklmnopqrstuvwxyz" random_id) add_custom_command( OUTPUT @@ -263,8 +264,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 /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libpng16.so.16.34.0,/usr/local/lib/python3.12/dist-packages/torchvision.libs/libpng16-748299c7.so.16.34.0> libpng16.so" - COMMAND /bin/sh -c "docker cp pytorch_backend_ptlib:$,/usr/lib64/libjpeg.so.62.2.0,/usr/local/lib/python3.12/dist-packages/torchvision.libs/libjpeg-da649728.so.62.2.0> libjpeg.so" + COMMAND /bin/sh -c "docker run --name libjpeg-${random_id} -it ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg* -exec cp -v {} /tmp/libjpeg.so \\; && docker cp libjpeg-${random_id}:/tmp/libjpeg.so libjpeg.so" + COMMAND /bin/sh -c "docker run --name libpng-${random_id} -it ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng* -exec cp -v {} /tmp/libpng16.so \\; && docker cp libpng-${random_id}:/tmp/libpng16.so libpng16.so" 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" From 6355a7b495a0b06c8e6a0f46dfe5229d8b790ab9 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 7 Nov 2024 22:51:03 -0800 Subject: [PATCH 6/8] Remov interactive flag --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e78a53..c4a1349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,8 +264,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 /bin/sh -c "docker run --name libjpeg-${random_id} -it ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg* -exec cp -v {} /tmp/libjpeg.so \\; && docker cp libjpeg-${random_id}:/tmp/libjpeg.so libjpeg.so" - COMMAND /bin/sh -c "docker run --name libpng-${random_id} -it ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng* -exec cp -v {} /tmp/libpng16.so \\; && docker cp libpng-${random_id}:/tmp/libpng16.so libpng16.so" + COMMAND /bin/sh -c "docker run --name libjpeg-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg* -exec cp -v {} /tmp/libjpeg.so \\; && docker cp libjpeg-${random_id}:/tmp/libjpeg.so libjpeg.so" + COMMAND /bin/sh -c "docker run --name libpng-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng* -exec cp -v {} /tmp/libpng16.so \\; && docker cp libpng-${random_id}:/tmp/libpng16.so libpng16.so" 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" From d7109fc6ab0b8a078e4268bd564c1eecaa4015e2 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 7 Nov 2024 23:24:24 -0800 Subject: [PATCH 7/8] Update CMake --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4a1349..0da2086 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,8 +264,10 @@ 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 /bin/sh -c "docker run --name libjpeg-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg* -exec cp -v {} /tmp/libjpeg.so \\; && docker cp libjpeg-${random_id}:/tmp/libjpeg.so libjpeg.so" - COMMAND /bin/sh -c "docker run --name libpng-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng* -exec cp -v {} /tmp/libpng16.so \\; && docker cp libpng-${random_id}:/tmp/libpng16.so libpng16.so" + COMMAND /bin/sh -c "docker run --name libjpeg-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg* -exec cp -v {} /tmp/libjpeg.so \\; || true" + COMMAND docker cp libjpeg-${random_id}:/tmp/libjpeg.so libjpeg.so + COMMAND /bin/sh -c "docker run --name libpng-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng* -exec cp -v {} /tmp/libpng16.so \\; || true" + COMMAND docker cp libpng-${random_id}:/tmp/libpng16.so libpng16.so 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" From 6b66690e3bdca803bf38e944c1d1d699461c7b47 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Sat, 9 Nov 2024 09:08:39 -0800 Subject: [PATCH 8/8] Update match pattern to pick shared object file only --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0da2086..ebb48ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,9 +264,9 @@ 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 /bin/sh -c "docker run --name libjpeg-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg* -exec cp -v {} /tmp/libjpeg.so \\; || true" + COMMAND /bin/sh -c "docker run --name libjpeg-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libjpeg*.so* -type f -exec cp -v {} /tmp/libjpeg.so \\; || true" COMMAND docker cp libjpeg-${random_id}:/tmp/libjpeg.so libjpeg.so - COMMAND /bin/sh -c "docker run --name libpng-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng* -exec cp -v {} /tmp/libpng16.so \\; || true" + COMMAND /bin/sh -c "docker run --name libpng-${random_id} ${TRITON_PYTORCH_DOCKER_IMAGE} find /usr/lib64 /usr/local/lib/python3.12/dist-packages/torchvision.libs/ -name libpng*.so* -type f -exec cp -v {} /tmp/libpng16.so \\; || true" COMMAND docker cp libpng-${random_id}:/tmp/libpng16.so libpng16.so 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"