Skip to content

Commit

Permalink
build: RHEL8 TensorFlow Backend (#105)
Browse files Browse the repository at this point in the history
* build: RHEL8 TF Backend
  • Loading branch information
fpetrini15 authored Aug 27, 2024
1 parent 80296d0 commit 73327cd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ if(TRITON_TENSORFLOW_LIB_PATHS STREQUAL "")
endif()
message(STATUS "Using Tensorflow docker: ${TRITON_TENSORFLOW_DOCKER_BUILD}")

set(RHEL_BUILD OFF)
if(LINUX)
file(STRINGS "/etc/os-release" DISTRO_ID_LIKE REGEX "ID_LIKE")
if(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
set(RHEL_BUILD ON)
endif(${DISTRO_ID_LIKE} MATCHES "rhel|centos")
endif(LINUX)

set(TRITON_TENSORFLOW_CC_LIBNAME "libtensorflow_cc.so")
set(TRITON_TENSORFLOW_FW_LIBNAME "libtensorflow_framework.so")
set(TRITON_TENSORFLOW_LDFLAGS "-ltensorflow_cc -ltensorflow_framework")
Expand All @@ -68,7 +76,11 @@ if(${TRITON_TENSORFLOW_VERSION} EQUAL "1")
elseif(${TRITON_TENSORFLOW_VERSION} EQUAL "2")
set(TRITON_TENSORFLOW_BACKEND_LIBNAME triton_tensorflow)
set(TRITON_TENSORFLOW_BACKEND_INSTALLDIR ${CMAKE_INSTALL_PREFIX}/backends/tensorflow)
set(TRITON_TENSORFLOW_PYTHON_PATH "/usr/local/lib/python3.10/dist-packages/tensorflow")
if(RHEL_BUILD)
set(TRITON_TENSORFLOW_PYTHON_PATH "/opt/_internal/cpython-3.10.13/lib/python3.10/site-packages/tensorflow")
else()
set(TRITON_TENSORFLOW_PYTHON_PATH "/usr/local/lib/python3.10/dist-packages/tensorflow")
endif(RHEL_BUILD)
else()
message(FATAL_ERROR "TRITON_TENSORFLOW_VERSION allowed values is '2'")
endif()
Expand Down Expand Up @@ -135,15 +147,15 @@ if (${TRITON_TENSORFLOW_DOCKER_BUILD})
COMMAND docker pull ${TRITON_TENSORFLOW_DOCKER_IMAGE}
COMMAND docker rm tensorflow_backend_tflib || echo "error ignored..." || true
COMMAND docker create --name tensorflow_backend_tflib ${TRITON_TENSORFLOW_DOCKER_IMAGE}
COMMAND docker cp -L tensorflow_backend_tflib:/usr/local/lib/tensorflow/${TRITON_TENSORFLOW_CC_LIBNAME}.${TRITON_TENSORFLOW_VERSION} ${TRITON_TENSORFLOW_CC_LIBNAME}.${TRITON_TENSORFLOW_VERSION}
COMMAND docker cp -L tensorflow_backend_tflib:${TRITON_TENSORFLOW_PYTHON_PATH}/${TRITON_TENSORFLOW_CC_LIBNAME}.${TRITON_TENSORFLOW_VERSION} ${TRITON_TENSORFLOW_CC_LIBNAME}.${TRITON_TENSORFLOW_VERSION}
COMMAND docker cp tensorflow_backend_tflib:${TRITON_TENSORFLOW_PYTHON_PATH}/${TRITON_TENSORFLOW_FW_LIBNAME}.${TRITON_TENSORFLOW_VERSION} ${TRITON_TENSORFLOW_FW_LIBNAME}.${TRITON_TENSORFLOW_VERSION}
COMMAND docker cp tensorflow_backend_tflib:/opt/tensorflow/tensorflow-source/LICENSE LICENSE.tensorflow
COMMAND docker rm tensorflow_backend_tflib

COMMAND docker stop tensorflow_backend_deps || echo "error ignored..." || true
COMMAND docker rm tensorflow_backend_deps || echo "error ignored..." || true
COMMAND if [ "${TRITON_TENSORFLOW_INSTALL_EXTRA_DEPS}" = "ON" ] \; then mkdir tf_backend_deps && docker run -it -d --name tensorflow_backend_deps ${TRITON_TENSORFLOW_DOCKER_IMAGE} \; fi \;
COMMAND if [ "${TRITON_TENSORFLOW_INSTALL_EXTRA_DEPS}" = "ON" ] \; then docker exec tensorflow_backend_deps sh -c "tar -cf - /usr/lib/${LIBS_ARCH}-linux-gnu/libnccl.so*" | tar --strip-components=3 -xf - -C ./tf_backend_deps \; fi
COMMAND if [ "${TRITON_TENSORFLOW_INSTALL_EXTRA_DEPS}" = "ON" ] \; then docker exec tensorflow_backend_deps sh -c "tar -cf - $<IF:$<BOOL:${RHEL_BUILD}>,/usr/local/cuda/targets/x86_64-linux/lib/,/usr/lib/${LIBS_ARCH}-linux-gnu/>libnccl.so*" | tar --strip-components=3 -xf - -C ./tf_backend_deps \; fi
COMMAND if [ "${TRITON_TENSORFLOW_INSTALL_EXTRA_DEPS}" = "ON" ] \; then docker stop tensorflow_backend_deps && docker rm tensorflow_backend_deps \; fi \;

COMMENT "Extracting ${TRITON_TENSORFLOW_CC_LIBNAME}.${TRITON_TENSORFLOW_VERSION} and ${TRITON_TENSORFLOW_FW_LIBNAME}.${TRITON_TENSORFLOW_VERSION} from ${TRITON_TENSORFLOW_DOCKER_IMAGE}"
Expand Down

0 comments on commit 73327cd

Please sign in to comment.