Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy HPCX paths for CPU images #113

Closed
wants to merge 14 commits into from
35 changes: 30 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,31 @@ set(OPENCV_LIBS
"libjpeg.so"
)

# In CPU-only mode, get the hpcx libraries neededby libtorch.so.
if(NOT TRITON_ENABLE_GPU)
set(HPCX_LIBS
"libucc.so.1"
"libucm.so.0"
"libucp.so.0"
"libucs.so.0"
"libuct.so.0"
)
add_custom_command(
OUTPUT
${HPCX_LIBS}
COMMAND docker pull ${TRITON_PYTORCH_DOCKER_IMAGE}
COMMAND docker rm pytorch_backend_hpcxlib || echo "error ignored..." || true
COMMAND docker create --name pytorch_backend_hpcxlib ${TRITON_PYTORCH_DOCKER_IMAGE}
COMMAND docker cp -L pytorch_backend_hpcxlib:/opt/hpcx/ucc/lib/libucc.so.1 libucc.so.1
COMMAND docker cp -L pytorch_backend_hpcxlib:/opt/hpcx/ucx/lib/libucm.so.0 libucm.so.0
COMMAND docker cp -L pytorch_backend_hpcxlib:/opt/hpcx/ucx/lib/libucp.so.0 libucp.so.0
COMMAND docker cp -L pytorch_backend_hpcxlib:/opt/hpcx/ucx/lib/libucs.so.0 libucs.so.0
COMMAND docker cp -L pytorch_backend_hpcxlib:/opt/hpcx/ucx/lib/libuct.so.0 libuct.so.0
COMMAND docker rm pytorch_backend_hpcxlib
VERBATIM
Comment on lines +193 to +213
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of modifying cmake can we copy over the whole /opt/hpcx/ucc/ and /opt/hpcx/ucx in the build.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will try this approach.

)
endif() # TRITON_ENABLE_GPU

# The patchelf commands ensure the MKL libraries are loaded correctly during runtime
# Without these, the framework/backend complains of missing libraries / symbols and
# in some cases leads to segmentation faults.
Expand Down Expand Up @@ -249,7 +274,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
COMMENT "Extracting pytorch and torchvision libraries and includes from ${TRITON_PYTORCH_DOCKER_IMAGE}"
VERBATIM
)
add_custom_target(ptlib_target DEPENDS ${PT_LIBS} ${LIBTORCH_LIBS} ${OPENCV_LIBS})
add_custom_target(ptlib_target DEPENDS ${PT_LIBS} ${HPCX_LIBS} ${LIBTORCH_LIBS} ${OPENCV_LIBS})
add_library(ptlib SHARED IMPORTED GLOBAL)
add_dependencies(ptlib ptlib_target)

Expand Down Expand Up @@ -415,7 +440,7 @@ install(

if (${TRITON_PYTORCH_DOCKER_BUILD})
set(PT_LIB_PATHS "")
FOREACH(plib ${PT_LIBS} ${LIBTORCH_LIBS} ${OPENCV_LIBS})
FOREACH(plib ${PT_LIBS} ${HPCX_LIBS} ${LIBTORCH_LIBS} ${OPENCV_LIBS})
set(PT_LIB_PATHS ${PT_LIB_PATHS} "${CMAKE_CURRENT_BINARY_DIR}/${plib}")
ENDFOREACH(plib)

Expand All @@ -434,7 +459,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
)
endif() # TRITON_PYTORCH_ENABLE_TORCHTRT

FOREACH(plib ${PT_LIBS} ${LIBTORCH_LIBS} ${OPENCV_LIBS})
FOREACH(plib ${PT_LIBS} ${HPCX_LIBS} ${LIBTORCH_LIBS} ${OPENCV_LIBS})
install(
CODE
"EXECUTE_PROCESS(
Expand Down Expand Up @@ -469,7 +494,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
endif()"
)
else()
FOREACH(plib ${PT_LIBS})
FOREACH(plib ${PT_LIBS} ${HPCX_LIBS})
set(PT_LIB_PATHS ${PT_LIB_PATHS} "${TRITON_PYTORCH_LIB_PATHS}/${plib}")
ENDFOREACH(plib)

Expand All @@ -479,7 +504,7 @@ else()
DESTINATION ${CMAKE_INSTALL_PREFIX}/backends/pytorch
)

FOREACH(plib ${PT_LIBS})
FOREACH(plib ${PT_LIBS} ${HPCX_LIBS})
install(
CODE
"EXECUTE_PROCESS(
Expand Down