diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fea1ac1ee1d9..706cb2934fa34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,7 +206,7 @@ cmake_dependent_option( option(USE_FBGEMM "Use FBGEMM (quantized 8-bit server operators)" ON) option(USE_KINETO "Use Kineto profiling library" ON) option(USE_BREAKPAD "Use breakpad crash dump library" ON) -option(USE_CUPTI_SO "Use CUPTI as a shared library" OFF) +option(USE_CUPTI_SO "Use CUPTI as a shared library" ON) option(USE_FAKELOWP "Use FakeLowp operators" OFF) option(USE_FFMPEG "Use ffmpeg" OFF) option(USE_GFLAGS "Use GFLAGS" OFF) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 564fcebc0b08c..b3dbcb3e71587 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -1960,6 +1960,24 @@ if(USE_KINETO) message(STATUS " CUDA_cupti_LIBRARY = ${CUDA_cupti_LIBRARY}") message(STATUS "Found CUPTI") set(LIBKINETO_NOCUPTI OFF CACHE STRING "" FORCE) + + include(CheckCXXSourceRuns) + unset(EXCEPTIONS_WORK CACHE) + set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--whole-archive,${CUPTI_LIBRARY_PATH},--no-whole-archive") + check_cxx_source_runs("#include +int main() { + try { + throw std::runtime_error(\"error\"); + } catch (...) { + return 0; + } + return 1; +}" EXCEPTIONS_WORK) + set(CMAKE_REQUIRED_LINK_OPTIONS "") + if(NOT EXCEPTIONS_WORK) + message(FATAL_ERROR "Detected that statically linking against CUPTI causes exceptions to stop working. See https://github.com/pytorch/pytorch/issues/57744 for more details. Perhaps try: USE_CUPTI_SO=1 python setup.py develop --cmake") + endif() + else() message(STATUS "Could not find CUPTI library, using CPU-only Kineto build") set(LIBKINETO_NOCUPTI ON CACHE STRING "" FORCE)