Skip to content

Commit d3b9a0b

Browse files
committed
change: CPU only build doesn't have CUDA_VERSION environment variable. Using flag to control library inclusion.
1 parent 4446242 commit d3b9a0b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

CMakeLists.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ option(TRITON_ENABLE_STATS "Include statistics collections in backend" ON)
5050
option(TRITON_ENABLE_NVTX "Include nvtx markers collection in backend." OFF)
5151
option(TRITON_PYTORCH_ENABLE_TORCHTRT "Enable TorchTRT support" OFF)
5252
option(TRITON_PYTORCH_ENABLE_TORCHVISION "Enable Torchvision support" ON)
53+
option(TRITON_PYTORCH_NVSHMEM "Enable NVSHMEM support" ON)
5354

5455
set(TRITON_PYTORCH_DOCKER_IMAGE "" CACHE STRING "Docker image containing the PyTorch build required by backend.")
5556
set(TRITON_PYTORCH_INCLUDE_PATHS "" CACHE PATH "Paths to Torch includes")
@@ -160,13 +161,9 @@ set(PT_LIBS
160161
"libtorch_cuda_linalg.so"
161162
"libtorch_global_deps.so"
162163
"libjpeg.so.62"
164+
$<IF:$<BOOL:${TRITON_PYTORCH_NVSHMEM}>,libtorch_nvshmem.so,>
163165
)
164166

165-
if($ENV{CUDA_VERSION} VERSION_GREATER_EQUAL "13.0.2.006")
166-
list(APPEND PT_LIBS "libtorch_nvshmem.so")
167-
set(NVSHMEM_LIB "libtorch_nvshmem.so")
168-
endif()
169-
170167
if (${TRITON_PYTORCH_ENABLE_TORCHVISION})
171168
set(PT_LIBS
172169
${PT_LIBS}
@@ -243,7 +240,7 @@ if (${TRITON_PYTORCH_DOCKER_BUILD})
243240
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libtorch_cuda_linalg.so libtorch_cuda_linalg.so
244241
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libtorch_global_deps.so libtorch_global_deps.so
245242
COMMAND docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libcaffe2_nvrtc.so libcaffe2_nvrtc.so
246-
COMMAND test -n "${NVSHMEM_LIB}" && docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libtorch_nvshmem.so libtorch_nvshmem.so
243+
COMMAND /bin/sh -c "if [ ${TRITON_PYTORCH_NVSHMEM} = 'ON' ]; then docker cp pytorch_backend_ptlib:${PY_INSTALL_PATH}/torch/lib/libtorch_nvshmem.so libtorch_nvshmem.so; fi"
247244
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"
248245
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"
249246
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"

0 commit comments

Comments
 (0)